Reputation: 39
I have a file and in one column 'Saracen ID' has multiple values and i want group basis those values like 1. ('07111',07112') should come under one group. 2. (09084) come under second group 3. Rest if any in future will fall under third group.
I am trying to group multiple grouping through groupby and get_group
group_1=df.groupby('Saracen ID').get_group('07111',07112')
group_2=df.groupby('Saracen ID')get_group('09084')
group_1
group_2
I am getting the error 'str' object has not attribute 'take'
How to get multiple groups under one grouping in pandas.
Upvotes: 1
Views: 414
Reputation: 323386
The way we filter the group is loc
+ isin
group_1 = df.loc[df['Saracen ID'].isin(['07111', '07112'])]
Upvotes: 1