Closed Tiptop4792 closed 9 months ago
Thanks for flagging this.
The error is in this line: https://github.com/bellingcat/wayback-google-analytics/blob/525ed217e527a979ba5c7a70a208366e28a1b752/wayback_google_analytics/output.py#L183
by inspection, the KeyError can only occur if the code_list
variable is empty []
. full code for that is here
To replicate:
import pandas as pd
df = pd.DataFrame([])
df.groupby("code")
# --> KeyError "code"
This means the results did not retrieve any valid codes, I'll wait for @jclark1913 's input, but the fix should be about not doing the groupby opeartion on empty code results.
Great catch here, @Tiptop4792 . I think @msramalho is spot on in his assessment - I'll step through the code to see if there are other KeyErrors when not finding codes and make a PR that fixes this issue.
Thank you @msramalho & @jclark1913 for the quick fix - it works! 👏
Hey! First of all: great tool - this can be super useful!
I've been dabbling around with it for a bit, but it still throws a lot of errors. I especially encounter a couple of issues with the start and end parameters, e.g.:
This one works:
wayback-google-analytics -u https://tagesschau.de https://washingtonpost.com https://nytimes.com https://spiegel.de -s 01/01/2015 -f yearly -o xlsx
While this one throws an error:
wayback-google-analytics -u https://tagesschau.de https://washingtonpost.com https://nytimes.com https://spiegel.de -e 01/01/2015 -f yearly -o xlsx
Also, this one doesn't work:
wayback-google-analytics -u https://tagesschau.de https://washingtonpost.com https://nytimes.com https://spiegel.de -s 01/01/2012 -e 01/01/2015 -f yearly -o xlsx
That's what I'm getting in the console:
Any idea what's going on? Many thanks!