Update app.py
Browse files
app.py
CHANGED
@@ -49,9 +49,21 @@ def heatmap(top_n):
|
|
49 |
api_name="/get_heatmap_pivot_table"
|
50 |
)
|
51 |
print(pivot_table)
|
52 |
-
print(type(pivot_table))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
-
|
|
|
|
|
55 |
|
56 |
plt.figure(figsize=(10, 8))
|
57 |
sns.heatmap(df,
|
|
|
49 |
api_name="/get_heatmap_pivot_table"
|
50 |
)
|
51 |
print(pivot_table)
|
52 |
+
print(type(pivot_table))
|
53 |
+
"""
|
54 |
+
pivot_table is a dict like:
|
55 |
+
{'headers': ['Index', 'economy', 'human rights', 'immigrant', 'politics'],
|
56 |
+
'data': [['anger', 55880.0, 557679.0, 147766.0, 180094.0],
|
57 |
+
['disgust', 26911.0, 123112.0, 64567.0, 46460.0],
|
58 |
+
['fear', 51466.0, 188898.0, 113174.0, 150578.0],
|
59 |
+
['neutral', 77005.0, 192945.0, 20549.0, 190793.0]],
|
60 |
+
'metadata': None}
|
61 |
+
"""
|
62 |
+
|
63 |
|
64 |
+
# transfere dictionary to df
|
65 |
+
df = pd.DataFrame(diction['data'], columns=diction['headers'])
|
66 |
+
df.set_index('Index', inplace=True)
|
67 |
|
68 |
plt.figure(figsize=(10, 8))
|
69 |
sns.heatmap(df,
|