x0rz / tweets_analyzer

Tweets metadata scraper & activity analyzer
GNU General Public License v3.0
2.95k stars 454 forks source link

collections.Counter() simplifies counting #3

Closed cclauss closed 7 years ago

cclauss commented 7 years ago

https://docs.python.org/2/library/collections.html#collections.Counter

x0rz commented 7 years ago

I don't know why but I'm getting this error (python2). I'm trying to figure out why right now

Traceback (most recent call last):
  File "tweets_analyzer.py", line 303, in <module>
    main()
  File "tweets_analyzer.py", line 269, in main
    print_charts(activity_weekly, "Weekly activity distribution (per day)", weekday=True)
  File "tweets_analyzer.py", line 211, in print_charts
    displayed_key = "%s (\033[92m+\033[0m)" % (int_to_weekday(key) if weekday else key)
  File "tweets_analyzer.py", line 182, in int_to_weekday
    return weekdays[day % len(weekdays)]
TypeError: not all arguments converted during string formatting
x0rz commented 7 years ago

Ok got it, had to add int(), day is a string return weekdays[int(day) % len(weekdays)]

cclauss commented 7 years ago

I thought about the ìnt()` thing on the metro this morning. Good that you caught it. You have a cool tool here...