Python Forum
Error Message Coming Up When Running Code - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Error Message Coming Up When Running Code (/thread-24367.html)



Error Message Coming Up When Running Code - eddywinch82 - Feb-10-2020

Hi there,

I have an Traceback Error, associated with the following line, of the Python Code I have :-

groupby_venue_date = selected.groupby(['Venue', 'BID', 'Date', 'DISPLAY/', 'Durn-Total'])
Which gives the following Traceback Error :-

Error:
File "<ipython-input-278-b2b43ed053c7>", line 47 groupby_venue_date = selected.groupby(['Venue', 'BID', 'Date', 'DISPLAY/', 'Durn-Total']) ^ SyntaxError: invalid syntax
It is proceeded by the following Line of Code :-

df['Durn-Total'] = df['Durn'].groupby(df['Venue'].sum()
With that line of Code, I am trying to Group the DataFrame Data, by the Column 'Venue', and Sum by the 'Durn' Row, creating a new Column 'Durn-Total' is that correct ? I was wondering if that line is causing the Error I am getting ? Could Someone suggest to me, what is causing the Error ?

Also I meant to say, I had an ')' bracket around the 'Venue' part of the Code, so saying :-

df['Durn-Total'] = df['Durn'].groupby(df['Venue']).sum()
But that gave an Traceback Error Of :-

Error:
TypeError: unsupported operand type(s) for +: 'datetime.time' and 'datetime.time'
And I am unsure, how to fix that Error in Code. I am assuming it's because calculations, can't be done, in the Time Format, the Values in the 'Durn' Column are, at that point in the Code ?

Any help would be appreciated

Regards

Eddie Winch