Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'DataFrame' object has no attribute 'group'

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.

like image 938
Boromir Avatar asked Apr 24 '18 03:04

Boromir


1 Answers

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

like image 112
rafaelc Avatar answered Oct 04 '22 14:10

rafaelc