Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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)
- # 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 'B' with the column mode
- df['B'].fillna(df['B'].mode())
Add Comment
Please, Sign In to add comment