Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. data['days_employed'] = data['days_employed'].apply(abs)
  2. days_employed_med = data.groupby(['education','income_type'], as_index = False)['days_employed'].median()
  3.  
  4. for index, row in days_employed_med.iterrows():
  5.     education = row['education']
  6.     income = row['income_type']
  7.     data.loc[(data['days_employed'].isnull()) & (data['education'] == education) & (data['income_type'] == income), 'days_employed'] = days_employed_med[(days_employed_med['education'] == education) & (days_employed_med['income_type'] == income)]['days_employed']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement