gpt4 book ai didi

python - 如何删除数据框的所有列都等于 None 的每一行

转载 作者:行者123 更新时间:2023-12-01 01:44:32 25 4
gpt4 key购买 nike

例如 data frame example我想删除所有列 = NA 的每一行。我不想删除所有列中都没有 NA 的行。请给出一些建议并举例说明。我非常感谢您的帮助。

最佳答案

你可以尝试:

df.dropna(how='all', inplace=True)

来自documentation (pandas.DataFrame.dropna) :

how : {‘any’, ‘all’}, default ‘any’

Determine if row or column is removed from DataFrame, when we have at least one NA or all NA.

‘any’ : If any NA values are present, drop that row or column.

‘all’ : If all values are NA, drop that row or column.

inplace :

inplace : bool, default False

If True, do operation inplace and return None.

关于python - 如何删除数据框的所有列都等于 None 的每一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51530311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com