From d2ff44e5d5d8f83356950a5018eaf91fbdf03896 Mon Sep 17 00:00:00 2001 From: CC Date: Tue, 1 Sep 2026 23:01:33 +0100 Subject: [PATCH] genre counts --- main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index fd7fc0a..42dfdcb 100644 --- a/main.py +++ b/main.py @@ -28,10 +28,16 @@ def fetch_titles_and_genres(engine: Engine) -> pd.DataFrame: query = """SELECT title, genres FROM audiobookshelf.ao3;""" return run_query(engine, query) +def count_genre_occurrences(data: pd.DataFrame, column: str = "genres") -> pd.Series: + """Count how many times each genre appears across all titles.""" + return data.explode(column)[column].value_counts() + def main(): engine = get_engine() data = fetch_titles_and_genres(engine) - print(data.head()) + genre_counts = count_genre_occurrences(data) + print(genre_counts) + # print(data.head()) if __name__ == "__main__":