Untitled

From Ungracious Bird, 8 Months ago, written in Plain Text, viewed 194 times.
URL http://codebin.org/view/fe397b1c Embed
Download Paste or View Raw
  1. def categorize_income(total_income):
  2.     if total_income <= 30000:
  3.         return 'E'
  4.     if total_income <= 50000:
  5.         return 'D'
  6.     if total_income <= 200000:
  7.         return 'C'
  8.     if total_income <= 1000000:
  9.         return 'B'
  10.     if total_income >= 1000001:
  11.         return 'A'
  12.     # создайте функцию categorize_income()
  13.  
  14. data['total_income_category'] = data['total_income'].apply(categorize_income)  # примените функцию методом apply()

Reply to "Untitled"

Here you can reply to the paste above