Alejandro Cremades commited on
Commit
50e3646
1 Parent(s): a006abf

Search both languages at once on Streamlit

Browse files
Files changed (1) hide show
  1. Middle_School_Card_List.py +9 -11
Middle_School_Card_List.py CHANGED
@@ -5,7 +5,7 @@ mslist_path = "output/middleschool.csv"
5
 
6
  st.write(
7
  """
8
- # Middle School Card List
9
  """
10
  )
11
 
@@ -13,16 +13,14 @@ mslist_df = pd.read_csv(mslist_path)
13
  mslist_df.fillna("", inplace=True)
14
  st.write(mslist_df.shape[0], "cards are legal")
15
 
16
- lang = st.radio("Card language", ("English", "Japanese"))
17
- name_input = st.text_input(f"Search by {lang} card name")
18
- lang_col = {
19
- "English": "name",
20
- "Japanese": "name_ja",
21
- }
22
-
23
- results_df = mslist_df[
24
- mslist_df[lang_col[lang]].str.contains(name_input.lower(), case=False)
25
  ]
 
26
  if name_input:
27
  st.write(results_df.shape[0], f'cards found by "{name_input}"')
28
- st.write(results_df[["name", "name_ja"]])
 
5
 
6
  st.write(
7
  """
8
+ # Middle School Card Search
9
  """
10
  )
11
 
 
13
  mslist_df.fillna("", inplace=True)
14
  st.write(mslist_df.shape[0], "cards are legal")
15
 
16
+ name_input = st.text_input(f"Search by card name")
17
+ results_en_df = mslist_df[
18
+ mslist_df["name"].str.contains(name_input.lower(), case=False)
19
+ ]
20
+ results_ja_df = mslist_df[
21
+ mslist_df["name_ja"].str.contains(name_input.lower(), case=False)
 
 
 
22
  ]
23
+ results_df = results_en_df.merge(results_ja_df, how="outer")
24
  if name_input:
25
  st.write(results_df.shape[0], f'cards found by "{name_input}"')
26
+ st.write(results_df[["name", "name_ja"]])