Reputation: 99
I'm clueless about this error. First I try
import pandas as pd
datafile = "E:\...\DPA.xlsx"
data = pd.read_excel(datafile)
data
And everything is fine. Then...
data.boxplot('DPA', by='Liga', figsize=(12, 8))
Everything keeps going fine. then...
ctrl = data['DPA'][data.group == 'PremierLeague']
grps = pd.unique(data.group.values)
d_data = {grp:data['DPA'][data.group == grp] for grp in grps}
k = len(pd.unique(data.group)) # number of conditions
N = len(data.values) # conditions times participants
n = data.groupby('Liga').size()[0] #Participants in each condition
And here is when I get this error:
AttributeError: 'DataFrame' object has no attribute 'group'
Any ideas? I'm following this steps https://www.marsja.se/four-ways-to-conduct-one-way-anovas-using-python/ to make an ANOVA.
Thank you.
Upvotes: 10
Views: 26713
Reputation: 59304
DataFrame
has no attribute group
. However, it is possible to access data in a column in your dataframe with the same syntax used to access attributes and methods, i.e. if you have a column col
, you may access the series related to this column through
df.col
What happened here is that your data is probably different from what she used in the tutorial. Or at least, the columns she has are different than the columns you have.
To solve that problem, you can either (I) simply rename your columns to match the columns from the tutorial or (II) replace data.group
with the corresponding column name that you have in your df
Upvotes: 1