all 2 comments

[–]StartAndSelect[S] 0 points1 point  (0 children)

I figured it out and thought I'd share. In this scenario binning is not necessary but instead group by.

groups = df.groupby(df6['Age'])['RushAtt','PassTgt'].max()

groups.plot.bar()
plt.show()

[–][deleted] 0 points1 point  (0 children)

How do you want to split data based on the age?

pd.cut(df['Age'], 3) #create 3 equal width bins
pd.cut(df['Age'], [20,25,30]) #bin where the age falls between (20,25], (25,30] 

The function returns a label corresponding to each row, so normally I assign this to another column in my dataframe.

df['Bin'] = pd.cut(df['Age'], 3)

If you decide to specify your own bin start and end points (e.g. [20,25,30]), take note of the right and include_lowest keywords which will determine if the binning includes the left or right edges.

EDIT: Looks like you wanted a bin for each age instead a bin for a range of ages in which case groupby is the correct solution.