Skip to content

Instantly share code, notes, and snippets.

@gugarosa
Last active January 3, 2021 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gugarosa/7356badfc2dd9ca24893a41a36283791 to your computer and use it in GitHub Desktop.
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.
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