最初に を構築しましょうctable:
import pandas as pd
import blaze as bl
df = pd.DataFrame({'x': range(4), 'y': [2., 4., 2., 4.]})
bl.odo(df, 'test.bcolz')
ここで、このテーブルに「x_mod」という列を追加したいとします。私は試した
test_table = bl.Data('test.bcolz')
def f(h):
return h*3
test_table['x_mod'] = test_table['x'].apply(f, dshape='int64')
#Or, I think equivalently:
#test_table['x_mod'] = test_table['x']*3
しかし、それは与えます
TypeError: 'InteractiveSymbol' object does not support item assignment
1) 「x_mod」列を割り当ててからディスクに保存するにはどうすればよいですか? 大規模なデータベースを扱っています。メモリ内の列を計算することは問題ないはずですが、全体ctableをメモリにロードする方法がありません。
2)関連する問題については、apply私にとってもうまくいきません。私は何か間違ったことをしていますか?
#This doesn't work:
bl.compute(test_table['x'].apply(f, dshape='int64'))
#This I think should be equivalent, but does work:
bl.compute(test_table['x']*3)
御時間ありがとうございます!