Skip to content

Instantly share code, notes, and snippets.

@sbenthall
Created May 30, 2023 12:33
Show Gist options
  • Save sbenthall/15af4d7edb5774303d71f56b42dfcd04 to your computer and use it in GitHub Desktop.
Save sbenthall/15af4d7edb5774303d71f56b42dfcd04 to your computer and use it in GitHub Desktop.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[9], line 1
----> 1 tempdata = mod_data.groupby(['From Gender','InReplyTo Gender','From'], as_index=False)['From','Subject'].count()
3 tempdata = pd.DataFrame(tempdata)
5 unique_interaction = pd.DataFrame(tempdata.groupby(['From Gender', 'InReplyTo Gender'],
6 as_index=False)['From'].count()).rename(columns={'From':'Count'})
File ~/projects/bigbang/bigbang-env/lib/python3.8/site-packages/pandas/core/groupby/generic.py:1769, in DataFrameGroupBy.__getitem__(self, key)
1765 # per GH 23566
1766 if isinstance(key, tuple) and len(key) > 1:
1767 # if len == 1, then it becomes a SeriesGroupBy and this is actually
1768 # valid syntax, so don't raise
-> 1769 raise ValueError(
1770 "Cannot subset columns with a tuple with more than one element. "
1771 "Use a list instead."
1772 )
1773 return super().__getitem__(key)
ValueError: Cannot subset columns with a tuple with more than one element. Use a list instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment