Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pandas Issue: 'DataFrame' object has no attribute 'get_group'

I’m trying to get different groups from a grouped dataframe in pandas, but I’m getting an error.

Here’s the code:

import pandas as pd 

table = pd.read_csv("April24_HD_T2_MMStack_Default_edges.csv")
table.drop(table.index[0:3], inplace = True)
table.groupby('TRACK_ID', sort = False)

zero = table.get_group('0')

The console outputs the following error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

‘DataFrame’ object has no attribute ‘get_group’

Any ideas about what I’m doing wrong?

>Solution :

The groupby is not an inplace operation and you need to assign the result to a variable in order to access get_group. So, simply just assign it back to the table:

import pandas as pd 

table = pd.read_csv("April24_HD_T2_MMStack_Default_edges.csv")
table.drop(table.index[0:3], inplace = True)
table = table.groupby('TRACK_ID', sort = False)

zero = table.get_group('0')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading