Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. '''Cleaning the *Profile* dataset'''
  2. profile = profile.dropna(axis=0, subset=['gender', 'income']);
  3. profile_gender = profile['gender'].str.get_dummies()
  4. profile_gender.columns = ['gender_' + col for col in profile_gender.columns];
  5. # Separate date attributes into year, month, and day, converting to integers.
  6. profile_date = profile['became_member_on'];
  7.  
  8. profile_year = profile_date.apply(lambda d: str(d)).str[0:4].astype('int').rename('member_year');
  9. profile_month = profile_date.apply(lambda d: str(d)).str[4:6].astype('int').rename('member_month');
  10. profile_day = profile_date.apply(lambda d: str(d)).str[6:8].astype('int').rename('member_day');
  11.  
  12. profile = pd.concat([profile, profile_gender, profile_year, profile_month, profile_day], axis=1);
  13.  
  14. profile = profile.drop(['became_member_on', 'gender'], axis=1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement