我调用dropna后,数据框的大小没有改变。但我希望删除所有缺少一个值的行。
import pandas as pd
if __name__ == '__main__':
# Import data
census_subdivision_profile = pd.read_csv('../data/augmented/census_subdivision_profile_merged.csv')
print(census_subdivision_profile.shape)
census_subdivision_profile.dropna()
print(census_subdivision_profile.shape)
答案 0 :(得分:1)
你忘了分配输出:
census_subdivision_profile = census_subdivision_profile.dropna()
或者将参数inplace=True
添加到DataFrame.dropna
:
census_subdivision_profile.dropna(inplace=True)