【发布时间】:2018-08-09 14:29:49
【问题描述】:
这应该可行:
raw_data.drop('some_great_column', axis=1).compute()
但是该列没有被删除。在我使用的熊猫中:
raw_data.drop(['some_great_column'], axis=1, inplace=True)
但在 Dask 中不存在 inplace。有什么想法吗?
【问题讨论】:
标签: python python-3.x pandas dask
这应该可行:
raw_data.drop('some_great_column', axis=1).compute()
但是该列没有被删除。在我使用的熊猫中:
raw_data.drop(['some_great_column'], axis=1, inplace=True)
但在 Dask 中不存在 inplace。有什么想法吗?
【问题讨论】:
标签: python python-3.x pandas dask
你可以分成两个操作:
# dask operation
raw_data = raw_data.drop('some_great_column', axis=1)
# conversion to pandas
df = raw_data.compute()
然后将 Pandas 数据框导出到 CSV 文件:
df.to_csv(r'out.csv', index=False)
【讨论】:
compute 时,即使在您的原始代码中,这也会发生无论如何。如果是这种情况,您可以尝试分组过滤和导出。
我假设您想将“原始数据”保存在 Dask DF 中。在这种情况下,以下方法可以解决问题:
new_raw_df = raw_data.drop('some_great_column', axis=1).copy()
其中type(new_raw_df)是dask.dataframe.core.DataFrame,你可以删除原来的DF。
【讨论】: