I cannot seem to print the following line: summarydata["Name"].groupby(["Tag"]).size()
without getting the error:
File "C:\Users\rspatel\untitled0.py", line 76, in <module>
print(summarydata["Name"].groupby(["Tag"]).size())
File "C:\Users\rspatel\Anaconda3\lib\site-packages\pandas\core\series.py", line 1720, in groupby
return SeriesGroupBy(
File "C:\Users\rspatel\Anaconda3\lib\site-packages\pandas\core\groupby\groupby.py", line 560, in __init__
grouper, exclusions, obj = get_grouper(
File "C:\Users\rspatel\Anaconda3\lib\site-packages\pandas\core\groupby\grouper.py", line 811, in get_grouper
raise KeyError(gpr)
KeyError: 'Tag'
I have checked that Tag is included as a column in the summarydata dataframe by the following:
if 'Tag' in summarydata.columns:
print("true")
else :
print("false")
which prints out as true. Therefore I am not sure why a key error is being thrown when the column is in the dataframe.