0

我想将我的 vaex 数据框的一列初始化为 int 值 0

我有以下内容:

right_csv = "animal_data.csv"

vaex_df = vaex.open(right_csv,dtype='object',convert=True)

vaex_df["initial_color"] = 0

但这将在第 3 行引发错误,抱怨 vaex 如何期待 str 表达式并得到一个整数。
如何使 vaex 表达式将列的每一行设置为单个值?

4

1 回答 1

2

好问题,现在最节省内存的方法(vaex-core v2.0.2,vaex v3)是:

df['test'] = vaex.vrange(0, len(df))  # add a 'virtual range' column, which takes no memory
df['test'] = df['test']* 0 + 111  # multiply by zero, and add the initial value

我们可能应该有一个更方便的方法来做到这一点,我为此打开了https://github.com/vaexio/vaex/issues/802

于 2020-06-04T19:56:46.323 回答