I have a df of people with their name and age and sex and other things.
I need to count number of people in each 10 years range.
for example i need to know how many womwns are in 0-10, 10-20, 20-30 till 90-100
I use this code
<code>for i in range(0,10):
n = '{} - {}'.format(i*10, i*10+9)
m = train_data.groupby("Age").apply(lambda x: x in (i*10, i*10+9)).count()
print(n,m)
</code>
<code>for i in range(0,10):
n = '{} - {}'.format(i*10, i*10+9)
m = train_data.groupby("Age").apply(lambda x: x in (i*10, i*10+9)).count()
print(n,m)
</code>
for i in range(0,10):
n = '{} - {}'.format(i*10, i*10+9)
m = train_data.groupby("Age").apply(lambda x: x in (i*10, i*10+9)).count()
print(n,m)
but it doesn’t work
New contributor
Hadees is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.