Last active
January 14, 2024 16:48
-
-
Save mmmayo13/7a81c3105001e503dbcb38ff23b74f9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Drop the columns where all elements are missing values: | |
df.dropna(axis=1, how='all') | |
# Drop the columns where any of the elements are missing values | |
df.dropna(axis=1, how='any') | |
# Keep only the rows which contain 2 missing values maximum | |
df.dropna(thresh=2) | |
# Drop the columns where any of the elements are missing values | |
df.dropna(axis=1, how='any') | |
# Fill all missing values with the mean of the particular column | |
df.fillna(df.mean()) | |
# Fill any missing value in column 'A' with the column median | |
df['A'].fillna(df['A'].median()) | |
# Fill any missing value in column 'Depeche' with the column mode | |
df['Depeche'].fillna(df['Depeche'].mode()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The second and fourth examples are the same.