import pandas as pd import matplotlib.pyplot as plt wnba = pd.read_csv('wnba.csv') wnba['PPG'] = wnba['PTS']/wnba['Games Played'] wnba_pos= wnba.groupby('Pos').sample(n= 10, random_state= 0)
What I expected to happen:
Hello everyone. I decided to use the pandas groupby method to stratify this dataset by player position. Also decided to use the groupby.sample method as seen above. I tried it on my command prompt and it worked., but when I tried it here on dataquest, I got the Attribute error described below. I’m not sure why I got this, considering that when I tried the same thing in my command prompt, it worked.
I noticed that the difference between the two obtained groupby objects was that the one in my command prompt is of class pandas.core.groupby.generic.DataFrameGroupBy whereas the one here on Dataquest is of class pandas.core.groupby.DataFrameGroupBy. I would really appreciate some help with this, an explanation perharps on why this happened and the difference if any between the two types.
AttributeError: Cannot access callable attribute ‘sample’ of ‘DataFrameGroupBy’ objects, try using the ‘apply’ method