In [1]:
import glob
import pandas
# read all files from pack/
files = glob.glob('pack/*.json')
packs = []
for file in files:
packs.append(pandas.read_json(file,orient='records'))
# Use Pandas for data analysis
cards = pandas.concat(packs,sort=False)
# use the unique card identifier as index
cards.set_index('code',inplace=True)
# remove duplicate cards (i.e. from the Core sets)
cards.drop_duplicates('title',inplace=True)
README.md describes the card JSON schema.
In [2]:
# read columns card title and type, sort by title
cards[['title','type_code']].sort_values(by='title').head(10)
Out[2]:
Find a specific card
In [10]:
# do not truncate strings
pandas.set_option('display.max_colwidth', -1)
cards[cards['title'].str.match('Noise')][['type_code','faction_code','title','text']]
Out[10]:
In [4]:
cards['type_code'].value_counts()
Out[4]:
In [8]:
cards['type_code'].value_counts().plot(kind='bar')
Out[8]:
In [6]:
programs = cards[cards['type_code'] == 'program']
programs['faction_code'].value_counts()
Out[6]:
ICE with faction and keywords
In [11]:
ice = cards[cards['type_code'] == 'ice']
ice[['title','faction_code','keywords']].head(10)
Out[11]:
In [ ]: