Dask:按索引从 Dataframe 中子集(或删除)行
Dask: subset (or drop) rows from Dataframe by index
我想根据一组索引键获取 Dask 数据帧的行的子集。 (具体来说,我想找到 ddf1 的索引不在 ddf2 的索引中的行。)
cache.drop([overlap_list])
和 diff = cache[should_keep_bool_array]
要么抛出 NotImplementedException 要么不工作。
最好的方法是什么?
我不确定这是 "best" 的方式,但我最终是这样做的:
- 创建一个 Pandas DataFrame,索引是我要保留的一系列索引键(例如,
pd.DataFrame(index=overlap_list)
)
- 内部加入Dask Dataframe
另一种可能是:
df_index = df.reset_index()
df_index = df_index.dorp_dplicates()
我想根据一组索引键获取 Dask 数据帧的行的子集。 (具体来说,我想找到 ddf1 的索引不在 ddf2 的索引中的行。)
cache.drop([overlap_list])
和 diff = cache[should_keep_bool_array]
要么抛出 NotImplementedException 要么不工作。
最好的方法是什么?
我不确定这是 "best" 的方式,但我最终是这样做的:
- 创建一个 Pandas DataFrame,索引是我要保留的一系列索引键(例如,
pd.DataFrame(index=overlap_list)
) - 内部加入Dask Dataframe
另一种可能是:
df_index = df.reset_index()
df_index = df_index.dorp_dplicates()