Pandas dropna()–从DataFrame中删除Null / NA值

本文详细介绍了Pandas的dropna()函数,用于从DataFrame中删除含有Null/NaN/NaT值的行和列。内容涵盖dropna()函数的参数用法,如axis、how、thresh和subset,以及不同参数设置下的示例,演示了如何根据特定条件删除数据。
摘要由CSDN通过智能技术生成

1. Pandas DataFrame dropna()函数 (1. Pandas DataFrame dropna() Function)

Pandas DataFrame dropna() function is used to remove rows and columns with Null/NaN values. By default, this function returns a new DataFrame and the source DataFrame remains unchanged.

Pandas DataFrame dropna()函数用于删除具有Null / NaN值的行和列。 默认情况下,此函数返回一个新的DataFrame,而源DataFrame保持不变。

We can create null values using None, pandas.NaT, and numpy.nan variables.

我们可以使用None,pandas.NaT和numpy.nan变量创建空值。

The dropna() function syntax is:

dropna()函数的语法为:

dropna(self, axis=0, how="any", thresh=None, subset=None, inplace=False)
  • axis: possible values are {0 or ‘index’, 1 or ‘columns’}, default 0. If 0, drop rows with null values. If 1, drop columns with missing values.

    axis :可能的值为{0或'index',1或'columns'},默认值为0。如果为0,则删除具有空值的行。 如果为1,则删除缺少值的列。
  • how: possible values are {‘any’, ‘all’}, default ‘any’. If ‘any’, drop the row/column if any of the values is null. If ‘all’, drop the row/column if all the values are missing.

    如何 :可能的值为{'any','all'},默认值为“ any”。 如果为“ any”,则在任何值为null的情况下删除行/列。 如果为“全部”,则在所有值均缺失的情况下删除行/列。
  • thresh: an int value to specify the threshold for the drop operation.

    thresh :一个整数
  • 3
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值