Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -57,7 +57,10 @@ def preprocess(text):
|
|
57 |
|
58 |
def highlight_survived(s):
|
59 |
return ['background-color: red']*len(s) if (s.Sexista == 1) else ['background-color: green']*len(s)
|
60 |
-
|
|
|
|
|
|
|
61 |
|
62 |
st.set_page_config(layout="wide")
|
63 |
st.markdown('<style>body{background-color: Blue;}</style>',unsafe_allow_html=True)
|
@@ -158,7 +161,11 @@ def run():
|
|
158 |
df = pd.DataFrame(list(zip(tweet_list, flat_predictions)),columns =['Últimos '+ str(number_of_tweets)+' Tweets'+' de '+search_words, 'Sexista'])
|
159 |
df['Sexista']= np.where(df['Sexista']== 0, 'No Sexista', 'Sexista')
|
160 |
|
161 |
-
|
|
|
|
|
|
|
|
|
162 |
#st.table(df)
|
163 |
#st.write(df)
|
164 |
run()
|
|
|
57 |
|
58 |
def highlight_survived(s):
|
59 |
return ['background-color: red']*len(s) if (s.Sexista == 1) else ['background-color: green']*len(s)
|
60 |
+
|
61 |
+
def color_survived(val):
|
62 |
+
color = 'red' if val==0 else 'yellow' if val==1 else 'green'
|
63 |
+
return f'background-color: {color}'
|
64 |
|
65 |
st.set_page_config(layout="wide")
|
66 |
st.markdown('<style>body{background-color: Blue;}</style>',unsafe_allow_html=True)
|
|
|
161 |
df = pd.DataFrame(list(zip(tweet_list, flat_predictions)),columns =['Últimos '+ str(number_of_tweets)+' Tweets'+' de '+search_words, 'Sexista'])
|
162 |
df['Sexista']= np.where(df['Sexista']== 0, 'No Sexista', 'Sexista')
|
163 |
|
164 |
+
|
165 |
+
st.table(df.reset_index(drop=True).head(20).style.applymap(color_survived, subset=['Sexista']))
|
166 |
+
|
167 |
+
|
168 |
+
#st.dataframe(df.style.apply(highlight_survived, axis=1))
|
169 |
#st.table(df)
|
170 |
#st.write(df)
|
171 |
run()
|