0

I have a .CSV file a snippet of which looks like this:

ID,SN,          Age,Gender,Item ID,Item Name,               Price

0,Lisim78,       20, Male,  108,   Extraction Quickblade,    3.53
1,Lisovynya38,   40, Male,  143,   Frenzied Scimitar,        1.56
2,Ithergue48,    24, Male,   92,   Final Critic,             4.88
3,Chamassasya86, 24, Male,  100,   Blindscythe,              3.27
4,Iskosia90,     23, Male,  131,   Fury,                     1.44
5,Yalae81,       22, Male,   81,   Dreamkiss,                3.61
6,Itheria73,     36, Male,  169,   Interrogator,             2.18
7,Iskjaskst81,   20, Male,  162,   Abyssal Shard,            2.67
8,Undjask33,     22, Male,   21,   Souleater,                 1.1
9,Chanosian48,   35, Other, 136,   Ghastly Adamantite,       3.58
10,Inguron55,     23, Male,   95,   Singed Onyx Warscythe,    4.74 

I need to establish bins for the 'Age' column which I have done like so:

bins = [0, 10, 15, 20, 25, 30, 35, 40, 45]
names = ['<10', '10-14', '15-19', '20-24', '25-29', '30-34', '35-39', '40+']
df_bins = pd.cut(df['Age'], bins, labels=names)

How do I use the bins to categorize other columns like column 'SN'? I wanna be able to get a count of all players in 'SN' column who are <10, 10-14, 15-19 years... and so on.

Any help is greatly appreciated!

Vaishali
  • 37,545
  • 5
  • 58
  • 86
Krithika Raghavendran
  • 457
  • 3
  • 10
  • 25

0 Answers0