Jung commited on
Commit
820e64b
·
1 Parent(s): 8e7bc1d

add power-filter, total num of filtered list

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -67,6 +67,9 @@ def display_image(url, scale=0.5):
67
  st.image(image.resize(( int(image.width * scale), int(image.height * scale))))
68
 
69
  def display_heroes_from_df(df,display_cols=display_cols):
 
 
 
70
  st.dataframe(df[display_cols],
71
  column_config={
72
  "image": st.column_config.ImageColumn("Avatar", help="")},
@@ -191,6 +194,7 @@ if genre == ':rainbow[Heroes Explorer]':
191
  st.header("Stat Filters")
192
  st.write("Tips: put the **minimum** att/def/hp stat you want to filter heroes")
193
  with st.expander("Stat Options"):
 
194
  defense_option = st.text_input(label="Defense:", value="0")
195
  attack_option = st.text_input(label="Attack:", value="0")
196
  health_option = st.text_input(label="Health:", value="0")
@@ -219,6 +223,10 @@ if genre == ':rainbow[Heroes Explorer]':
219
  if source_option != 'None':
220
  idx_all.append(filter_by_1col(df, 'source', source_option, exact_flag=False))
221
 
 
 
 
 
222
  if defense_option != "0":
223
  defense_option = int(defense_option)
224
  idx_all.append(filter_by_1col_num(df, 'defense', defense_option, oper_flag="ge"))
@@ -238,7 +246,7 @@ if genre == ':rainbow[Heroes Explorer]':
238
  idx_all.append(filter_by_1col(df, 'effects', special_text_option, exact_flag=False))
239
 
240
  #########################################
241
- st.header(f'Updated: Oct 23, 2023 -- Total heroes = {len(df)}')
242
 
243
  df2 = df[np.all(idx_all,axis=0)]
244
 
 
67
  st.image(image.resize(( int(image.width * scale), int(image.height * scale))))
68
 
69
  def display_heroes_from_df(df,display_cols=display_cols):
70
+ vtob = "is" if len(df)<=1 else "are"
71
+ st.write(f'There {vtob} {len(df)} heroes in the filtered list')
72
+
73
  st.dataframe(df[display_cols],
74
  column_config={
75
  "image": st.column_config.ImageColumn("Avatar", help="")},
 
194
  st.header("Stat Filters")
195
  st.write("Tips: put the **minimum** att/def/hp stat you want to filter heroes")
196
  with st.expander("Stat Options"):
197
+ power_option = st.text_input(label="Power:", value="0")
198
  defense_option = st.text_input(label="Defense:", value="0")
199
  attack_option = st.text_input(label="Attack:", value="0")
200
  health_option = st.text_input(label="Health:", value="0")
 
223
  if source_option != 'None':
224
  idx_all.append(filter_by_1col(df, 'source', source_option, exact_flag=False))
225
 
226
+ if power_option != "0":
227
+ power_option = int(power_option)
228
+ idx_all.append(filter_by_1col_num(df, 'power', power_option, oper_flag="ge"))
229
+
230
  if defense_option != "0":
231
  defense_option = int(defense_option)
232
  idx_all.append(filter_by_1col_num(df, 'defense', defense_option, oper_flag="ge"))
 
246
  idx_all.append(filter_by_1col(df, 'effects', special_text_option, exact_flag=False))
247
 
248
  #########################################
249
+ st.write(f'### Updated: Oct 23, 2023 -- Total heroes in HeroPlan database = {len(df)}')
250
 
251
  df2 = df[np.all(idx_all,axis=0)]
252