Last active
January 3, 2021 16:39
-
-
Save gugarosa/7356badfc2dd9ca24893a41a36283791 to your computer and use it in GitHub Desktop.
Creates an array for comparing whether certain Pokémon exists or not in a TCG set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
from pokemontcgsdk import Card, Set | |
# Sets to be searched | |
SETS = ['g1', 'sm1', 'sm2', 'sm4', 'sm6', 'sm7', | |
'sm11', 'sm12', 'swsh1', 'swsh2', 'swsh3', 'swsh4'] | |
# Instantiates an array of cards from all sets | |
cards_sets = np.zeros((894, len(SETS))) | |
# Iterates through all desired sets | |
for i, SET in enumerate(SETS): | |
print(SET) | |
# Finds all cards | |
cards = Card.where(setCode=SET, supertype='pokemon') | |
# Iterates through all cards | |
for card in cards: | |
# Checks if number really exists | |
if card.national_pokedex_number is not None: | |
# Marks the card | |
cards_sets[card.national_pokedex_number, i] = 1 | |
# Creates a data frame and increments its index | |
df = pd.DataFrame(cards_sets) | |
# Outsputs to a file | |
df.to_csv('out.csv', header=SETS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment