Guest User

Untitled

a guest
Apr 23rd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. # Having the following Dataframe:
  2.  
  3. First Second Third Fourth
  4. 0 NaN 2 NaN 0
  5. 1 3 4 NaN 1
  6. 2 NaN NaN NaN 5
  7. 3 4 1 2 3
  8.  
  9.  
  10. # by default dropna() removes rows with NaN in ANY of the colums
  11.  
  12. df.dropna()
  13.  
  14. First Second Third Fourth
  15. 3 4 1 2 3
  16.  
  17. # Remove NaN only from an specific column
  18.  
  19. df.dropna(subset=['Second'])
  20.  
  21. First Second Third Fourth
  22. 0 NaN 2 NaN 0
  23. 1 3 4 NaN 1
  24. 3 4 1 2 3
Add Comment
Please, Sign In to add comment