Skip to content

Instantly share code, notes, and snippets.

@pybites
Created September 8, 2023 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pybites/ede284c2f3bae914c2a1ddf9378d3f7b to your computer and use it in GitHub Desktop.
Save pybites/ede284c2f3bae914c2a1ddf9378d3f7b to your computer and use it in GitHub Desktop.
# 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