Alejandro Cremades commited on
Commit
3b6aade
1 Parent(s): d22f04b

Add CSV and JSON files including banned cards with banned==False

Browse files
list_scripts/7_remove_banned_cards.py CHANGED
@@ -35,6 +35,7 @@ banlist = [
35
  ]
36
 
37
  middleschool_df = pd.read_csv("data/middleschool_all_sets_added_japanese_names.csv")
 
38
 
39
  print("Cards legal by set:", middleschool_df.shape[0])
40
  # Find the rows with the banned cards
@@ -42,6 +43,7 @@ banned_df = middleschool_df[
42
  pd.DataFrame(middleschool_df.name.tolist()).isin(banlist).any(axis=1).values
43
  ]
44
  print("Banned cards:", banned_df.shape[0])
 
45
  # Append the banned cards to the main Middle School DataFrame,
46
  # then remove any rows that appear twice,
47
  # effectively leaving only the legal cards
@@ -51,6 +53,16 @@ middleschool_df = middleschool_df.reset_index(drop=True)
51
  middleschool_df = middleschool_df[["oracle_id", "name", "name_ja"]]
52
  middleschool_df = middleschool_df.sort_values(by=["name", "name_ja"])
53
 
54
- # Write a CSV file
 
 
 
 
 
 
 
 
55
  middleschool_df.to_csv("static/middleschool.csv")
56
  middleschool_df.to_json("static/middleschool.json")
 
 
 
35
  ]
36
 
37
  middleschool_df = pd.read_csv("data/middleschool_all_sets_added_japanese_names.csv")
38
+ ms_with_banned_df = middleschool_df
39
 
40
  print("Cards legal by set:", middleschool_df.shape[0])
41
  # Find the rows with the banned cards
 
43
  pd.DataFrame(middleschool_df.name.tolist()).isin(banlist).any(axis=1).values
44
  ]
45
  print("Banned cards:", banned_df.shape[0])
46
+
47
  # Append the banned cards to the main Middle School DataFrame,
48
  # then remove any rows that appear twice,
49
  # effectively leaving only the legal cards
 
53
  middleschool_df = middleschool_df[["oracle_id", "name", "name_ja"]]
54
  middleschool_df = middleschool_df.sort_values(by=["name", "name_ja"])
55
 
56
+ # Make a dataframe including the banned cards,
57
+ ms_with_banned_df["banned"] = ms_with_banned_df["name"].apply(lambda x: x in banlist)
58
+ ms_with_banned_df = ms_with_banned_df.reset_index(drop=True)
59
+ ms_with_banned_df = ms_with_banned_df[["oracle_id", "name", "name_ja", "banned"]]
60
+ ms_with_banned_df = ms_with_banned_df.sort_values(by=["name", "name_ja"])
61
+ print(ms_with_banned_df[ms_with_banned_df["name"] == "Balance"])
62
+ print(ms_with_banned_df[ms_with_banned_df["name"] == "Lightning Bolt"])
63
+
64
+ # Write CSV and JSON files
65
  middleschool_df.to_csv("static/middleschool.csv")
66
  middleschool_df.to_json("static/middleschool.json")
67
+ ms_with_banned_df.to_csv("static/middleschool_with_banned.csv")
68
+ ms_with_banned_df.to_json("static/middleschool_with_banned.json")
list_scripts/8_add_other_fields.py CHANGED
@@ -38,6 +38,7 @@ def add_other_fields(row: pd.DataFrame) -> pd.DataFrame:
38
 
39
 
40
  middleschool_df = pd.read_csv("static/middleschool.csv")
 
41
  with open("data/middleschool.json") as json_data:
42
  cards = json.loads(json_data.read())
43
 
@@ -45,5 +46,11 @@ middleschool_df = middleschool_df.apply(add_other_fields, axis=1)
45
  middleschool_df["power"] = middleschool_df["power"].astype("Int64")
46
  middleschool_df["toughness"] = middleschool_df["toughness"].astype("Int64")
47
 
 
 
 
 
48
  middleschool_df.to_csv("static/middleschool_extra_fields.csv")
49
  middleschool_df.to_json("static/middleschool_extra_fields.json")
 
 
 
38
 
39
 
40
  middleschool_df = pd.read_csv("static/middleschool.csv")
41
+ ms_with_banned_df = pd.read_csv("static/middleschool_with_banned.csv")
42
  with open("data/middleschool.json") as json_data:
43
  cards = json.loads(json_data.read())
44
 
 
46
  middleschool_df["power"] = middleschool_df["power"].astype("Int64")
47
  middleschool_df["toughness"] = middleschool_df["toughness"].astype("Int64")
48
 
49
+ ms_with_banned_df = ms_with_banned_df.apply(add_other_fields, axis=1)
50
+ ms_with_banned_df["power"] = ms_with_banned_df["power"].astype("Int64")
51
+ ms_with_banned_df["toughness"] = ms_with_banned_df["toughness"].astype("Int64")
52
+
53
  middleschool_df.to_csv("static/middleschool_extra_fields.csv")
54
  middleschool_df.to_json("static/middleschool_extra_fields.json")
55
+ ms_with_banned_df.to_csv("static/middleschool_extra_fields_with_banned.csv")
56
+ ms_with_banned_df.to_json("static/middleschool_extra_fields_with_banned.json")
static/middleschool_extra_fields_with_banned.csv ADDED
The diff for this file is too large to render. See raw diff
 
static/middleschool_extra_fields_with_banned.json ADDED
The diff for this file is too large to render. See raw diff
 
static/middleschool_with_banned.csv ADDED
The diff for this file is too large to render. See raw diff
 
static/middleschool_with_banned.json ADDED
The diff for this file is too large to render. See raw diff