Created
September 8, 2023 12:48
-
-
Save pybites/ede284c2f3bae914c2a1ddf9378d3f7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prior step done: | |
# python manage.py dumpdata auth.User --output=users.json --format=json | |
from collections import Counter | |
import json | |
import plotext as plt | |
def aggregate_users_by_year_month(filename="users.json"): | |
cnt = Counter() | |
with open(filename) as f: | |
data = json.load(f) | |
for row in data: | |
yy_mm = row["fields"]["date_joined"][:7] | |
cnt[yy_mm] += 1 | |
return cnt | |
def show_plot(data): | |
labels, values = zip(*data.items()) | |
plt.bar(labels, values) | |
plt.title("Pybites Platform User Signups per month") | |
plt.show() | |
if __name__ == "__main__": | |
data = aggregate_users_by_year_month() | |
show_plot(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment