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
Happened to me when I accidentally created MultiIndex columns:
>>> values = np.asarray([[1, 1], [2, 2], [3, 3]])
# notice accidental double brackets around column list
>>> df = pd.DataFrame(values, columns=[["foo", "bar"]])
# prints very innocently
>>> df
foo bar
0 1 1
1 2 2
2 3 3
# but throws this error
>>> df.groupby("foo")
ValueError: Grouper for 'foo' not 1-dimensional
# cause:
>>> df.columns
MultiIndex(levels=[['bar', 'foo']],
labels=[[1, 0]])
# fix by using correct columns list
>>> df = pd.DataFrame(values, columns=["foo", "bar"])
>>> df.groupby("foo")