Guest User

Untitled

a guest
Jan 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. # Filling in NaN values of a particular feature variable
  2. avg_height = 67 # Maybe this is a good number
  3. data["height"] = data["height"].fillna(avg_height)
  4.  
  5. # Filling in NaN values with a calculated one
  6. avg_height = data["height"].median() # This is probably more accurate
  7. data["height"] = data["height"].fillna(avg_height)
  8.  
  9. # Dropping rows with missing values
  10. # Here we check which rows of "height" aren't null
  11. # and only keep those
  12. data = data[pd.notnull(data['height'])]
Add Comment
Please, Sign In to add comment