Remove missing values.
See the User Guide for more on which values are considered missing, and how to work with missing data.
Determine if rows or columns which contain missing values are removed.
0, or âindexâ : Drop rows which contain missing values.
1, or âcolumnsâ : Drop columns which contain missing value.
Only a single axis is allowed.
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.
Require that many non-NA values. Cannot be combined with how.
Labels along other axis to consider, e.g. if you are dropping rows these would be a list of columns to include.
Whether to modify the DataFrame rather than creating a new one.
False
If True
, the resulting axis will be labeled 0, 1, â¦, n - 1.
Added in version 2.0.0.
DataFrame with NA entries dropped from it or None if inplace=True
.
Examples
>>> df = pd.DataFrame({"name": ['Alfred', 'Batman', 'Catwoman'], ... "toy": [np.nan, 'Batmobile', 'Bullwhip'], ... "born": [pd.NaT, pd.Timestamp("1940-04-25"), ... pd.NaT]}) >>> df name toy born 0 Alfred NaN NaT 1 Batman Batmobile 1940-04-25 2 Catwoman Bullwhip NaT
Drop the rows where at least one element is missing.
>>> df.dropna() name toy born 1 Batman Batmobile 1940-04-25
Drop the columns where at least one element is missing.
>>> df.dropna(axis='columns') name 0 Alfred 1 Batman 2 Catwoman
Drop the rows where all elements are missing.
>>> df.dropna(how='all') name toy born 0 Alfred NaN NaT 1 Batman Batmobile 1940-04-25 2 Catwoman Bullwhip NaT
Keep only the rows with at least 2 non-NA values.
>>> df.dropna(thresh=2) name toy born 1 Batman Batmobile 1940-04-25 2 Catwoman Bullwhip NaT
Define in which columns to look for missing values.
>>> df.dropna(subset=['name', 'toy']) name toy born 1 Batman Batmobile 1940-04-25 2 Catwoman Bullwhip NaT
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4