SHARE
TWEET

Untitled

a guest Jan 20th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2.  
  3. d = {'Gender': ['F','F','F','F','M'],
  4.     'Age': ['0-17','0-17','0-17','0-17','+55']
  5.     }
  6. df = pd.DataFrame(data=d)
  7. print(df)
  8.  
  9.   Gender   Age
  10. 0      F  0-17
  11. 1      F  0-17
  12. 2      F  0-17
  13. 3      F  0-17
  14. 4      M   +55
  15.    
  16. df.loc[df['Age'] == '0-17', 'Age'] = '17'
  17. df.loc[df['Age'] == '+55', 'Age'] = '60'
  18.  
  19. print(df)
  20.  
  21.   Gender Age
  22. 0      F  17
  23. 1      F  17
  24. 2      F  17
  25. 3      F  17
  26. 4      M  55
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top