# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 2
#     language: python
#     name: python2
# ---

import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
# %matplotlib inline

# Loading the previously cleaned data from it's CSV file
hs_dataframe = pd.read_csv('hearthstone_dataframe.csv')
hs_dataframe.columns

# +
# Color Pallete for Seaborn
classes_palette = {'Druid': '#FF7D0A', 'Warrior': '#C79C6E', 'Hunter': '#ABD473', 'Warlock': '#9482C9', 
                   'Mage':'#69CCF0', 'Shaman': '#0070DE', 'Paladin': '#F58CBA', 'Rogue': '#FFF569', 'Priest': '#FFFFFF'}

classes_label = ['Druid', 'Warrior', 'Hunter', 'Warlock', 'Mage', 'Shaman', 'Paladin', 'Rogue', 'Priest']
class_colors = ['#FF7D0A', '#C79C6E', '#ABD473', '#9482C9', '#69CCF0', '#0070DE', '#F58CBA', '#FFF569', '#FFFFFF']

# Plotting Cards Distribution Per Class
cards_per_class = hs_dataframe['playerClass'].value_counts()
classes = cards_per_class.keys()
cards_count = cards_per_class.values
explode = (0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1)

# MatplotLib 'SubPlots' Handler
fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(10,5))

# Pie Plot
axes.set_title('Cards Distribution Per Class (On our Dataset)', y=1.05)
axes.pie(cards_count, labels=classes, colors=class_colors, explode=explode,
        autopct='%1.1f%%', shadow=True, startangle=90)
axes.axis('equal')
# -

# Loading hearthstone Dataframe to Seaborn Engine
hs_dataframe['type'].unique()
hs_minions_dataframe = hs_dataframe[hs_dataframe['type'] == 'Minion'][['cost', 'health', 'attack', 'type']]
sns.pairplot(hs_minions_dataframe, hue='type', kind='scatter')
plt.suptitle('Distribution of Cards per Cost, Attack and Health (Minions)', y=1.05)
plt.show()

# +
fig, axs = plt.subplots(figsize=(15,5), ncols=3, nrows=1)

# Distribution of Minions Per Cost, Attack and Health
sns.distplot(hs_minions_dataframe['cost'], kde=False, bins=11, ax=axs[0])
sns.distplot(hs_minions_dataframe['attack'], kde=False, bins=13, ax=axs[1])
sns.distplot(hs_minions_dataframe['health'], kde=False, bins=15, ax=axs[2])

axs[0].set_ylabel('Cards Count')

axs[0].set_title('Dist. Per Cost')
axs[1].set_title('Dist. Per Attack')
axs[2].set_title('Dist. Per Health')
plt.show()

# +
# Cards Distribution Per Type and Class
fig, axs = plt.subplots(figsize=(15,5), ncols=1, nrows=1)
hs_cards_dataset = hs_dataframe[['playerClass', 'health', 'attack', 'type']]

axs.set_title('Distribution of Card Types Per Class')
sns.countplot(x='type',data=hs_cards_dataset, hue='playerClass', palette=classes_palette, ax=axs)
plt.show()
# -

hs_dataframe.columns

# +
# Plotting Cards Distribution Per Class
cards_per_class = hs_dataframe['rarity'].value_counts()
classes = cards_per_class.keys()
cards_count = cards_per_class.values
explode = (0.1, 0.1, 0.1, 0.1, 0.1)

rarity_colors = ['#ffffff', '#0070ff', '#EFEFEF', '#ff8000', '#a335ee']

# MatplotLib 'SubPlots' Handler
fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(10,5))

# Pie Plot
axes.set_title('Cards Distribution Per Rarity (On our Dataset)', y=1.05)
axes.pie(cards_count, labels=classes, colors=rarity_colors, explode=explode,
        autopct='%1.1f%%', shadow=True, startangle=90)
axes.axis('equal')
plt.show()
# -



StarcoderdataJupyterScriptsDedupFiltered