I\'m have the following code which creates a table and a barplot via seaborn.
#Building a dataframe grouped by the # of Engagement Types
sales_type = sales.g
I also ran into this problem, and found the cause of it and the obvious solution
To recreate this:
df = pd.DataFrame({"foo": [1,2,3], "bar": [1,2,3]})
df.rename(columns={'foo': 'bar'}, inplace=True)
bar bar
0 1 1
1 2 2
2 3 3
df.groupby('bar')
ValueError: Grouper for 'bar' not 1-dimensional
Just like a lot of cryptic pandas errors, this one too stems from having two columns with the same name.
Figure out which one you want to use, rename or drop the other column and redo the operation.
Rename the columns like this
df.columns = ['foo', 'bar']
foo bar
0 1 1
1 2 2
2 3 3
df.groupby('bar')