jitesh commited on
Commit
aa1abb2
1 Parent(s): dfd7729

updates styles

Browse files
Files changed (1) hide show
  1. src/read_logs.py +24 -4
src/read_logs.py CHANGED
@@ -73,6 +73,7 @@ class LogAnalyser:
73
  step=.01,)
74
  table_mode = self.container_param.radio(
75
  "Table Style:", ["Dataframe", "Table"])
 
76
  for story_id in self.df.Story.unique():
77
  reaction_num = 0
78
 
@@ -97,18 +98,37 @@ class LogAnalyser:
97
  self.df.at[index, 'reaction_show'] = reaction_show
98
  for story_id in self.df.Story.unique():
99
  dfs = self.df[(self.df.Story == story_id)].copy()
100
- dfs.drop('Story', axis=1, inplace=True)
 
101
  st.markdown(f'#### Story {story_id}')
102
- dfs = dfs.style.apply(self.rower, axis=None).set_table_styles([{
 
 
 
103
  'selector': 'tr:hover',
104
- 'props': 'font-size: 1.1em;' # background-color: #eeee66;
105
- }])
 
106
  if table_mode == 'Dataframe':
107
  st.dataframe(dfs) # set_na_rep(" ").s
108
  elif table_mode == 'Table':
109
  st.table(dfs)
 
110
 
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  @staticmethod
113
  @st.cache
114
  def rower(data):
 
73
  step=.01,)
74
  table_mode = self.container_param.radio(
75
  "Table Style:", ["Dataframe", "Table"])
76
+ # self.show_pe_data = self.container_param.checkbox('Show Probability Emote', value=True, key='show_pe_data_log')
77
  for story_id in self.df.Story.unique():
78
  reaction_num = 0
79
 
 
98
  self.df.at[index, 'reaction_show'] = reaction_show
99
  for story_id in self.df.Story.unique():
100
  dfs = self.df[(self.df.Story == story_id)].copy()
101
+ for c in ['Unnamed: 0', 'Story']:
102
+ dfs.drop(c, axis=1, inplace=True)
103
  st.markdown(f'#### Story {story_id}')
104
+ dfs = dfs.style
105
+ # if not self.show_pe_data:
106
+ # dfs = dfs.hide_columns(["reaction_frequency", "probability_emote", "random_value", "reaction_show"])
107
+ dfs = dfs.apply(self.rower, axis=None).set_table_styles([{
108
  'selector': 'tr:hover',
109
+ 'props': 'font-size: 1.01em;' # background-color: #eeee66;
110
+ }]).applymap(self.dfstyle_color_text) # .hide_index()
111
+
112
  if table_mode == 'Dataframe':
113
  st.dataframe(dfs) # set_na_rep(" ").s
114
  elif table_mode == 'Table':
115
  st.table(dfs)
116
+ print(dfs.render())
117
 
118
 
119
+ @staticmethod
120
+ @st.cache
121
+ def dfstyle_color_text(val):
122
+ if type(val)==str:
123
+ color = 'red' if val =='neutral' else 'black'
124
+ # elif type(val)==float:
125
+ # color = 'red' if val > .50000 else 'black'
126
+ elif val==None:
127
+ color = '#ffffff'
128
+ else:
129
+ color = 'black'
130
+ return 'color: %s' % color
131
+
132
  @staticmethod
133
  @st.cache
134
  def rower(data):