feat: add count into emotion per topic
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user