Alejandro Cremades commited on
Commit
d3537a9
β€’
1 Parent(s): 642bcd2

Move split_names_list function to lib

Browse files
pages/1_Check_Card_List.py CHANGED
@@ -5,16 +5,6 @@ import streamlit_common.lib as lib
5
 
6
  mslist_path = "output/middleschool.csv"
7
 
8
-
9
- def split_names_list(row: pd.DataFrame):
10
- if not isinstance(row["legalnames"], list):
11
- return row
12
- row["English"] = row["legalnames"][0]
13
- if row["legalnames"][1] is not None:
14
- row["ζ—₯本θͺž"] = row["legalnames"][1]
15
- return row
16
-
17
-
18
  st.set_page_config(
19
  page_title="Middle School | Check Card List",
20
  page_icon="πŸƒ",
@@ -51,7 +41,7 @@ input_cards["Legal"] = input_cards["cardname"].apply(
51
  input_cards["legalnames"] = input_cards["cardname"].apply(
52
  lib.get_legal_cardnames, args=[mslist_df]
53
  )
54
- input_cards = input_cards.apply(split_names_list, axis=1)
55
 
56
  col2.write("##### Middle School legality")
57
  col2.dataframe(input_cards[["Legal", "English", "ζ—₯本θͺž"]], use_container_width=True)
 
5
 
6
  mslist_path = "output/middleschool.csv"
7
 
 
 
 
 
 
 
 
 
 
 
8
  st.set_page_config(
9
  page_title="Middle School | Check Card List",
10
  page_icon="πŸƒ",
 
41
  input_cards["legalnames"] = input_cards["cardname"].apply(
42
  lib.get_legal_cardnames, args=[mslist_df]
43
  )
44
+ input_cards = input_cards.apply(lib.split_names_list, axis=1)
45
 
46
  col2.write("##### Middle School legality")
47
  col2.dataframe(input_cards[["Legal", "English", "ζ—₯本θͺž"]], use_container_width=True)
streamlit_common/lib.py CHANGED
@@ -55,3 +55,13 @@ def is_cardname_legal(cardname: str, mslist_df: pd.DataFrame) -> bool:
55
  if mslist_df[mslist_df["name_ja"] == cardname].shape[0] > 0:
56
  return True
57
  return False
 
 
 
 
 
 
 
 
 
 
 
55
  if mslist_df[mslist_df["name_ja"] == cardname].shape[0] > 0:
56
  return True
57
  return False
58
+
59
+
60
+ def split_names_list(row: pd.DataFrame):
61
+ """Splits the English and Japanese card names in a list into two different columns"""
62
+ if not isinstance(row["legalnames"], list):
63
+ return row
64
+ row["English"] = row["legalnames"][0]
65
+ if row["legalnames"][1] is not None:
66
+ row["ζ—₯本θͺž"] = row["legalnames"][1]
67
+ return row