输入数据框(df)
Country Region Date Value.....
ABW NaN 01-01-2020 123
ABW NaN 02-01-2020 1234
ABW NaN 03-01-2020 3242
USA NaN 04-01-2020 4354
USA NaN 05-01-2020 43543
USA NaN 06-01-2020 34534
USA NaN 07-01-2020 435
USA WA 08-01-2020 43345
USA WA 09-01-2020 345
USA WV 10-01-2020 345
.
.
.
.
预期输出(df1)
Country Region Date Value.....
ABW NaN 01-01-2020 123
ABW NaN 02-01-2020 1234
ABW NaN 03-01-2020 3242
USA NaN 04-01-2020 4354
USA NaN 05-01-2020 43543
USA NaN 06-01-2020 34534
USA NaN 07-01-2020 435
.
.
.
.
因此,从上面的数据框中,您可以看到列'Region
'具有NaN以及非空值,我想删除列'Region
'具有列的整个行非NaN值。
此外,执行完上述操作后,如果我想完全删除Region
列,如何以最快的方式(10k +列)来完成?专家,请帮忙!
最终预期输出
Country Date Value.....
ABW 01-01-2020 123
ABW 02-01-2020 1234
ABW 03-01-2020 3242
USA 04-01-2020 4354
USA 05-01-2020 43543
USA 06-01-2020 34534
USA 07-01-2020 435
这是我尝试的代码
df1=df1.isnull(df1['Region'])
错误
df1=df.isnull(df['Region'])
TypeError: isnull() takes 1 positional argument but 2 were given
答案 0 :(得分:0)
使用@BEN_YO的建议,这就是我所做的,效果很好
filtered_df = df1[df1['Region'].isnull()]