Screen Link:
My Code:
age_proportions = wnba['Age'].value_counts(normalize=True).sort_index()*100
proportion_25 = age_proportions[25]/100
percentage_30 = age_proportions[30]
percentage_over_30 = age_proportions[30:].sum()
percentage_below_23 = age_proportions[:23].sum()
What I expected to happen:
I expect to get the summary of percentages for percentage_over_30
and percentage_below_23
.
What actually happened:
I get no values
When I look at the solution it’s the same code but using .loc
I do not understand why .loc
needs to be specified here. The shorthand convention for choosing a slice of a series is Series[x:y]. It is even more confusing because the other lines of code use this exact syntax and are able to get the correct values.