Guest User

Untitled

a guest
Dec 11th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. # Drop the columns where all elements are missing values:
  2. df.dropna(axis=1, how='all')
  3.  
  4. # Drop the columns where any of the elements are missing values
  5. df.dropna(axis=1, how='any')
  6.  
  7. # Keep only the rows which contain 2 missing values maximum
  8. df.dropna(thresh=2)
  9.  
  10. # Fill all missing values with the mean of the particular column
  11. df.fillna(df.mean())
  12.  
  13. # Fill any missing value in column 'A' with the column median
  14. df['A'].fillna(df['A'].median())
  15.  
  16. # Fill any missing value in column 'B' with the column mode
  17. df['B'].fillna(df['B'].mode())
Add Comment
Please, Sign In to add comment