feat: add count into emotion per topic

This commit is contained in:
2026-02-08 15:41:57 +00:00
parent f6d612ca5e
commit f136e7b7c8

View File

@@ -198,6 +198,15 @@ class StatGen:
if col.startswith("emotion_") and col != "emotion_neutral"
]
counts = (
self.df[
(self.df["topic"] != "Misc")
]
.groupby("topic")
.size()
.rename("n")
)
avg_emotion_by_topic = (
self.df[
(self.df["topic"] != "Misc")
@@ -207,6 +216,11 @@ class StatGen:
.reset_index()
)
avg_emotion_by_topic = avg_emotion_by_topic.merge(
counts,
on="topic"
)
return {
"word_frequencies": word_frequencies.to_dict(orient='records'),
"average_emotion_by_topic": avg_emotion_by_topic.to_dict(orient='records')