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 :一个整数