top_frameworks.py 804 B

123456789101112131415161718192021222324252627282930
  1. from collections import Counter, defaultdict
  2. from scripts.utils import games
  3. import pandas as pd
  4. def main():
  5. c = Counter()
  6. framework_langs = defaultdict(Counter)
  7. for game in games():
  8. for framework in game.get("frameworks", []):
  9. c[framework] += 1
  10. for lang in game.get("langs", []):
  11. framework_langs[framework][lang] += 1
  12. most_common = c.most_common(10)
  13. rows = []
  14. for framework, count in most_common:
  15. framework_lang_counts = framework_langs[framework].most_common(5)
  16. row = {"framework": framework, "total": count}
  17. for i, lang in enumerate(framework_lang_counts):
  18. row[f"lang{i+1}"] = lang
  19. rows.append(row)
  20. df = pd.DataFrame(rows)
  21. print(df)
  22. if __name__ == "__main__":
  23. main()