Untitled

From Sweltering Pintail, 1 Year ago, written in Plain Text, viewed 182 times.
URL http://codebin.org/view/cf8c69be Embed
Download Paste or View Raw
  1. def categorize_income(row):
  2.     total_income = row['total_income']
  3.     if 0 <= total_income <= 30000:
  4.         return  'E'
  5.     if 30001 <= total_income <= 50000:
  6.         return  'D'
  7.     if 50001 <= total_income <= 200000:
  8.         return  'C'
  9.     if 200001 <= total_income <= 1000000:
  10.         return  'B'
  11.     if 1000001 <= total_income:
  12.         return  'A'
  13. row_values = ['E']
  14. row_columns = ['total_income']
  15. row = pd.Series(data=row_values, index=row_columns)
  16.  
  17. data['total_income_category'] = data.apply(categorize_income, axis=1)

Reply to "Untitled"

Here you can reply to the paste above