Jung commited on
Commit
a2fe95b
·
1 Parent(s): 1764877

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -5
app.py CHANGED
@@ -49,7 +49,7 @@ def display_image(url, scale=0.5):
49
 
50
  def display_heroes_from_df(df):
51
  display_cols = ['image','name', 'color', 'star', 'class', 'speed', 'power', 'attack', 'defense', 'health', 'types', 'source', 'family']
52
- df[display_cols]
53
  st.dataframe(df[display_cols],
54
  column_config={
55
  "image": st.column_config.ImageColumn("Avatar", help="")},
@@ -65,14 +65,43 @@ def display_heroes_from_df(df):
65
  # st.write(sp)
66
 
67
  #########################################
68
-
69
 
70
  df = pd.read_csv('heroes_ep.csv')
 
 
 
 
71
 
 
 
 
 
 
 
 
 
 
72
  idx_all = []
73
- idx_all.append(filter_by_1col(df, 'types', 'hit 3'))
74
- idx_all.append(filter_by_1col(df, 'effects', 'dispel'))
75
- idx_all.append(filter_by_1col(df, 'speed', 'fast', exact_flag=False))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
  df2 = df[np.all(idx_all,axis=0)]
78
 
 
49
 
50
  def display_heroes_from_df(df):
51
  display_cols = ['image','name', 'color', 'star', 'class', 'speed', 'power', 'attack', 'defense', 'health', 'types', 'source', 'family']
52
+
53
  st.dataframe(df[display_cols],
54
  column_config={
55
  "image": st.column_config.ImageColumn("Avatar", help="")},
 
65
  # st.write(sp)
66
 
67
  #########################################
68
+ ## Load the main file (TODO: caching)=
69
 
70
  df = pd.read_csv('heroes_ep.csv')
71
+ class_values = ['None'] + list(df['class'].unique())
72
+ star_values = ['None'] + list(df['star'].unique())
73
+ color_values = ['None'] + list(df['color'].unique())
74
+ speed_values = ['None'] + list(df['speed'].unique())
75
 
76
+ #########################################
77
+ ## Select options
78
+ with st.sidebar:
79
+ # star_option = st.selectbox(label='Speed:', options=star_values, index=5)
80
+ color_option = st.selectbox(label='Color:', options=color_values, index=0)
81
+ speed_option = st.selectbox(label='Speed:', options=speed_values, index=0)
82
+ class_option = st.selectbox(label='Class:', options=class_values, index=0)
83
+ special_type_option = st.text_input(label="SpecialSkill Category", value="Hit 3")
84
+ special_text_option = st.text_input(label="SpecialSkill Text", value="Dispel")
85
  idx_all = []
86
+ # if star_option is not None:
87
+ # idx_all.append(filter_by_1col(df, 'star', star_option, exact_flag=False))
88
+
89
+ if speed_option is not None:
90
+ idx_all.append(filter_by_1col(df, 'speed', speed_option, exact_flag=True))
91
+
92
+ if color_option is not None:
93
+ idx_all.append(filter_by_1col(df, 'color', color_option, exact_flag=False))
94
+
95
+ if class_option is not None:
96
+ idx_all.append(filter_by_1col(df, 'class', class_option, exact_flag=False))
97
+
98
+ if special_type_option is not None:
99
+ idx_all.append(filter_by_1col(df, 'types', special_type_option, exact_flag=False))
100
+
101
+ if special_text_option is not None:
102
+ idx_all.append(filter_by_1col(df, 'effects', special_text_option, exact_flag=False))
103
+
104
+ #########################################
105
 
106
  df2 = df[np.all(idx_all,axis=0)]
107