daily pastebin goal
70%
SHARE
TWEET

labelEncoder

a guest Sep 23rd, 2018 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Importing the dataset
  2. data = pd.read_csv('clean_medrec.csv', delimiter=";")
  3.  
  4. # Label encoder
  5. le = LabelEncoder()
  6. df1 = pd.DataFrame(data, columns=['gender','district_name'])
  7. df2 = pd.DataFrame(data, columns=['code','age_category'])
  8.  
  9. data1 = data['code']
  10. data2 = data['age_category']
  11.  
  12. x1 = le.fit_transform(data1)
  13. x2 = le.fit_transform(data2)
  14.  
  15. df2 = pd.DataFrame(x1)
  16. df2.columns = ['code']
  17. df3 = pd.DataFrame(x2)
  18. df3.columns = ['age_category']
  19. df_result = pd.concat([df1, df2, df3], axis=1)
  20. print(df_result)
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