如何从Dask数据框中移除包含NaN值的行?
- 内容介绍
- 文章标签
- 相关推荐
本文共计319个文字,预计阅读时间需要2分钟。
我有一个模糊的数据框架,我想在其中删除`selling_price`列中包含NAN值的所有行。
python示例代码import pandas as pdimport numpy as np
创建示例数据框架data={ 'selling_price': [100, np.nan, 200, 300, np.nan], 'product_id': [1, 2, 3, 4, 5], 'category': ['A', 'B', 'C', 'D', 'E']}df=pd.DataFrame(data)
删除包含NAN的行df_cleaned=df.dropna(subset=['selling_price'])
显示结果print(df_cleaned.head(3))
我有一个模糊的数据框,我想在其中删除“selling_price”列中具有NAN值的所有行image_我有一个模糊的数据框,我想在其中删除“ selling_price”列中具有NAN值的所有行
image_features_df.head(3) feat1 feat2 feat3 ... feat25087 feat25088 fid selling_price0 0.0 0.0 0.0 ... 0.0 0.0 2 269.001 0.2 0.0 0.8 ... 0.0 0.3 22 NAN 2 0.5 0.0 0.4 ... 0.0 0.1 70 NAN
上表显示了我的数据框的视图。
我希望输出为dask数据框,而我的“ selling_price”列中没有任何NAN单元。
预期输出:
image_features_df.head(3) feat1 feat2 feat3 ... feat25087 feat25088 fid selling_price0 0.0 0.0 0.0 ... 0.0 0.0 2 269.004 0.3 0.1 0.0 ... 0.0 0.3 26 1720.00 6 0.8 0.0 0.0 ... 0.0 0.1 50 18145.25
请尝试以下操作,如果在Selling_price列中找到NaN,则会删除行。
# Im just guessing the name of the helper
本文共计319个文字,预计阅读时间需要2分钟。
我有一个模糊的数据框架,我想在其中删除`selling_price`列中包含NAN值的所有行。
python示例代码import pandas as pdimport numpy as np
创建示例数据框架data={ 'selling_price': [100, np.nan, 200, 300, np.nan], 'product_id': [1, 2, 3, 4, 5], 'category': ['A', 'B', 'C', 'D', 'E']}df=pd.DataFrame(data)
删除包含NAN的行df_cleaned=df.dropna(subset=['selling_price'])
显示结果print(df_cleaned.head(3))
我有一个模糊的数据框,我想在其中删除“selling_price”列中具有NAN值的所有行image_我有一个模糊的数据框,我想在其中删除“ selling_price”列中具有NAN值的所有行
image_features_df.head(3) feat1 feat2 feat3 ... feat25087 feat25088 fid selling_price0 0.0 0.0 0.0 ... 0.0 0.0 2 269.001 0.2 0.0 0.8 ... 0.0 0.3 22 NAN 2 0.5 0.0 0.4 ... 0.0 0.1 70 NAN
上表显示了我的数据框的视图。
我希望输出为dask数据框,而我的“ selling_price”列中没有任何NAN单元。
预期输出:
image_features_df.head(3) feat1 feat2 feat3 ... feat25087 feat25088 fid selling_price0 0.0 0.0 0.0 ... 0.0 0.0 2 269.004 0.3 0.1 0.0 ... 0.0 0.3 26 1720.00 6 0.8 0.0 0.0 ... 0.0 0.1 50 18145.25
请尝试以下操作,如果在Selling_price列中找到NaN,则会删除行。
# Im just guessing the name of the helper

