Vera-ZWY commited on
Commit
51319c6
1 Parent(s): 9fc9533

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
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)) # it's a dict
 
 
 
 
 
 
 
 
 
 
53
 
54
- df = pd.DataFrame.from_dict(pivot_table)
 
 
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,