In [2]:
import pandas as pd
# Lib de visualition
import seaborn as sns
import matplotlib.pyplot as plt
# Pour que les graphique s'affichent dans le notebook
%matplotlib inline 


# Pour afficher des images (pas besoin de taper cet import)
from IPython.display import Image

In [4]:
# Chargement du fichier
data = pd.read_csv("../data/pokemon_data/pokemon.csv")

In [5]:
# Détail sur le fichier
data.shape


Out[5]:
(800, 13)

In [6]:
# On affiche le fichier
data


Out[6]:
# Name Type 1 Type 2 Total HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary
0 1 Bulbasaur Grass Poison 318 45 49 49 65 65 45 1 False
1 2 Ivysaur Grass Poison 405 60 62 63 80 80 60 1 False
2 3 Venusaur Grass Poison 525 80 82 83 100 100 80 1 False
3 3 VenusaurMega Venusaur Grass Poison 625 80 100 123 122 120 80 1 False
4 4 Charmander Fire NaN 309 39 52 43 60 50 65 1 False
5 5 Charmeleon Fire NaN 405 58 64 58 80 65 80 1 False
6 6 Charizard Fire Flying 534 78 84 78 109 85 100 1 False
7 6 CharizardMega Charizard X Fire Dragon 634 78 130 111 130 85 100 1 False
8 6 CharizardMega Charizard Y Fire Flying 634 78 104 78 159 115 100 1 False
9 7 Squirtle Water NaN 314 44 48 65 50 64 43 1 False
10 8 Wartortle Water NaN 405 59 63 80 65 80 58 1 False
11 9 Blastoise Water NaN 530 79 83 100 85 105 78 1 False
12 9 BlastoiseMega Blastoise Water NaN 630 79 103 120 135 115 78 1 False
13 10 Caterpie Bug NaN 195 45 30 35 20 20 45 1 False
14 11 Metapod Bug NaN 205 50 20 55 25 25 30 1 False
15 12 Butterfree Bug Flying 395 60 45 50 90 80 70 1 False
16 13 Weedle Bug Poison 195 40 35 30 20 20 50 1 False
17 14 Kakuna Bug Poison 205 45 25 50 25 25 35 1 False
18 15 Beedrill Bug Poison 395 65 90 40 45 80 75 1 False
19 15 BeedrillMega Beedrill Bug Poison 495 65 150 40 15 80 145 1 False
20 16 Pidgey Normal Flying 251 40 45 40 35 35 56 1 False
21 17 Pidgeotto Normal Flying 349 63 60 55 50 50 71 1 False
22 18 Pidgeot Normal Flying 479 83 80 75 70 70 101 1 False
23 18 PidgeotMega Pidgeot Normal Flying 579 83 80 80 135 80 121 1 False
24 19 Rattata Normal NaN 253 30 56 35 25 35 72 1 False
25 20 Raticate Normal NaN 413 55 81 60 50 70 97 1 False
26 21 Spearow Normal Flying 262 40 60 30 31 31 70 1 False
27 22 Fearow Normal Flying 442 65 90 65 61 61 100 1 False
28 23 Ekans Poison NaN 288 35 60 44 40 54 55 1 False
29 24 Arbok Poison NaN 438 60 85 69 65 79 80 1 False
... ... ... ... ... ... ... ... ... ... ... ... ... ...
770 700 Sylveon Fairy NaN 525 95 65 65 110 130 60 6 False
771 701 Hawlucha Fighting Flying 500 78 92 75 74 63 118 6 False
772 702 Dedenne Electric Fairy 431 67 58 57 81 67 101 6 False
773 703 Carbink Rock Fairy 500 50 50 150 50 150 50 6 False
774 704 Goomy Dragon NaN 300 45 50 35 55 75 40 6 False
775 705 Sliggoo Dragon NaN 452 68 75 53 83 113 60 6 False
776 706 Goodra Dragon NaN 600 90 100 70 110 150 80 6 False
777 707 Klefki Steel Fairy 470 57 80 91 80 87 75 6 False
778 708 Phantump Ghost Grass 309 43 70 48 50 60 38 6 False
779 709 Trevenant Ghost Grass 474 85 110 76 65 82 56 6 False
780 710 PumpkabooAverage Size Ghost Grass 335 49 66 70 44 55 51 6 False
781 710 PumpkabooSmall Size Ghost Grass 335 44 66 70 44 55 56 6 False
782 710 PumpkabooLarge Size Ghost Grass 335 54 66 70 44 55 46 6 False
783 710 PumpkabooSuper Size Ghost Grass 335 59 66 70 44 55 41 6 False
784 711 GourgeistAverage Size Ghost Grass 494 65 90 122 58 75 84 6 False
785 711 GourgeistSmall Size Ghost Grass 494 55 85 122 58 75 99 6 False
786 711 GourgeistLarge Size Ghost Grass 494 75 95 122 58 75 69 6 False
787 711 GourgeistSuper Size Ghost Grass 494 85 100 122 58 75 54 6 False
788 712 Bergmite Ice NaN 304 55 69 85 32 35 28 6 False
789 713 Avalugg Ice NaN 514 95 117 184 44 46 28 6 False
790 714 Noibat Flying Dragon 245 40 30 35 45 40 55 6 False
791 715 Noivern Flying Dragon 535 85 70 80 97 80 123 6 False
792 716 Xerneas Fairy NaN 680 126 131 95 131 98 99 6 True
793 717 Yveltal Dark Flying 680 126 131 95 131 98 99 6 True
794 718 Zygarde50% Forme Dragon Ground 600 108 100 121 81 95 95 6 True
795 719 Diancie Rock Fairy 600 50 100 150 100 150 50 6 True
796 719 DiancieMega Diancie Rock Fairy 700 50 160 110 160 110 110 6 True
797 720 HoopaHoopa Confined Psychic Ghost 600 80 110 60 150 130 70 6 True
798 720 HoopaHoopa Unbound Psychic Dark 680 80 160 60 170 130 80 6 True
799 721 Volcanion Fire Water 600 80 110 120 130 90 70 6 True

800 rows × 13 columns

On souhaite regarder uniquement les pokémons de 1ère génération. Il va donc falloir filtrer nos données

On va donc crée une nouvelle variable qui aura uniquement les pokémons de "Generation" = 1


In [10]:
pokemon = data[data.Generation == 1]

Voila comment sélectionner des données sur un DataFrame existant :)


In [11]:
Image(url="http://i.giphy.com/yidUzHnBk32Um9aMMw.gif")


Out[11]:

In [12]:
pokemon


Out[12]:
# Name Type 1 Type 2 Total HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary
0 1 Bulbasaur Grass Poison 318 45 49 49 65 65 45 1 False
1 2 Ivysaur Grass Poison 405 60 62 63 80 80 60 1 False
2 3 Venusaur Grass Poison 525 80 82 83 100 100 80 1 False
3 3 VenusaurMega Venusaur Grass Poison 625 80 100 123 122 120 80 1 False
4 4 Charmander Fire NaN 309 39 52 43 60 50 65 1 False
5 5 Charmeleon Fire NaN 405 58 64 58 80 65 80 1 False
6 6 Charizard Fire Flying 534 78 84 78 109 85 100 1 False
7 6 CharizardMega Charizard X Fire Dragon 634 78 130 111 130 85 100 1 False
8 6 CharizardMega Charizard Y Fire Flying 634 78 104 78 159 115 100 1 False
9 7 Squirtle Water NaN 314 44 48 65 50 64 43 1 False
10 8 Wartortle Water NaN 405 59 63 80 65 80 58 1 False
11 9 Blastoise Water NaN 530 79 83 100 85 105 78 1 False
12 9 BlastoiseMega Blastoise Water NaN 630 79 103 120 135 115 78 1 False
13 10 Caterpie Bug NaN 195 45 30 35 20 20 45 1 False
14 11 Metapod Bug NaN 205 50 20 55 25 25 30 1 False
15 12 Butterfree Bug Flying 395 60 45 50 90 80 70 1 False
16 13 Weedle Bug Poison 195 40 35 30 20 20 50 1 False
17 14 Kakuna Bug Poison 205 45 25 50 25 25 35 1 False
18 15 Beedrill Bug Poison 395 65 90 40 45 80 75 1 False
19 15 BeedrillMega Beedrill Bug Poison 495 65 150 40 15 80 145 1 False
20 16 Pidgey Normal Flying 251 40 45 40 35 35 56 1 False
21 17 Pidgeotto Normal Flying 349 63 60 55 50 50 71 1 False
22 18 Pidgeot Normal Flying 479 83 80 75 70 70 101 1 False
23 18 PidgeotMega Pidgeot Normal Flying 579 83 80 80 135 80 121 1 False
24 19 Rattata Normal NaN 253 30 56 35 25 35 72 1 False
25 20 Raticate Normal NaN 413 55 81 60 50 70 97 1 False
26 21 Spearow Normal Flying 262 40 60 30 31 31 70 1 False
27 22 Fearow Normal Flying 442 65 90 65 61 61 100 1 False
28 23 Ekans Poison NaN 288 35 60 44 40 54 55 1 False
29 24 Arbok Poison NaN 438 60 85 69 65 79 80 1 False
... ... ... ... ... ... ... ... ... ... ... ... ... ...
136 127 Pinsir Bug NaN 500 65 125 100 55 70 85 1 False
137 127 PinsirMega Pinsir Bug Flying 600 65 155 120 65 90 105 1 False
138 128 Tauros Normal NaN 490 75 100 95 40 70 110 1 False
139 129 Magikarp Water NaN 200 20 10 55 15 20 80 1 False
140 130 Gyarados Water Flying 540 95 125 79 60 100 81 1 False
141 130 GyaradosMega Gyarados Water Dark 640 95 155 109 70 130 81 1 False
142 131 Lapras Water Ice 535 130 85 80 85 95 60 1 False
143 132 Ditto Normal NaN 288 48 48 48 48 48 48 1 False
144 133 Eevee Normal NaN 325 55 55 50 45 65 55 1 False
145 134 Vaporeon Water NaN 525 130 65 60 110 95 65 1 False
146 135 Jolteon Electric NaN 525 65 65 60 110 95 130 1 False
147 136 Flareon Fire NaN 525 65 130 60 95 110 65 1 False
148 137 Porygon Normal NaN 395 65 60 70 85 75 40 1 False
149 138 Omanyte Rock Water 355 35 40 100 90 55 35 1 False
150 139 Omastar Rock Water 495 70 60 125 115 70 55 1 False
151 140 Kabuto Rock Water 355 30 80 90 55 45 55 1 False
152 141 Kabutops Rock Water 495 60 115 105 65 70 80 1 False
153 142 Aerodactyl Rock Flying 515 80 105 65 60 75 130 1 False
154 142 AerodactylMega Aerodactyl Rock Flying 615 80 135 85 70 95 150 1 False
155 143 Snorlax Normal NaN 540 160 110 65 65 110 30 1 False
156 144 Articuno Ice Flying 580 90 85 100 95 125 85 1 True
157 145 Zapdos Electric Flying 580 90 90 85 125 90 100 1 True
158 146 Moltres Fire Flying 580 90 100 90 125 85 90 1 True
159 147 Dratini Dragon NaN 300 41 64 45 50 50 50 1 False
160 148 Dragonair Dragon NaN 420 61 84 65 70 70 70 1 False
161 149 Dragonite Dragon Flying 600 91 134 95 100 100 80 1 False
162 150 Mewtwo Psychic NaN 680 106 110 90 154 90 130 1 True
163 150 MewtwoMega Mewtwo X Psychic Fighting 780 106 190 100 154 100 130 1 True
164 150 MewtwoMega Mewtwo Y Psychic NaN 780 106 150 70 194 120 140 1 True
165 151 Mew Psychic NaN 600 100 100 100 100 100 100 1 False

166 rows × 13 columns

Regardons les stats de Pikachu maintenant. Pour afficher les données, on n'a pas besoin de créer une nouvelle variable. Tout dépend de l'analyse que vous voulez faire par la suite


In [13]:
# Afficher les données de Pikachu :
pokemon[pokemon.Name == 'Pikachu']


Out[13]:
# Name Type 1 Type 2 Total HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary
30 25 Pikachu Electric NaN 320 35 55 40 50 50 90 1 False

In [28]:
# Creer une variable de attribut de Pikachu
Pikachu = pokemon[pokemon.Name == 'Pikachu']
Pikachu


Out[28]:
# Name Type 1 Type 2 Total HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary Att_Def my_def
30 25 Pikachu Electric NaN 320 35 55 40 50 50 90 1 False 95 75

In [16]:
Image(url="http://i.giphy.com/xuXzcHMkuwvf2.gif")


Out[16]:

On peut regarder quelle pokemon a le plus d'HP

Pandas dispose de fonctions simples et user-friendly. Pour trouver le maximum, il suffit de donner :

  • Le DataFrame (le nom de la variable)
  • l'attribut (son nom) : "Attack" etc...
  • la fonction à exécuter (en l'occurence .max() ici)

In [ ]:


In [ ]:


In [17]:
# le plus grand nombre d'HP dans le DataFrame pokemon
pokemon['HP'].max()


Out[17]:
250

In [18]:
# Si l'on souhaite trouver le pokemon en question il suffit de faire comme pour la sélection de Pikachu :
pokemon[pokemon['HP'] == 250]


Out[18]:
# Name Type 1 Type 2 Total HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary
121 113 Chansey Normal NaN 450 250 5 5 35 105 50 1 False

In [19]:
# On peux très bien le faire de façon dynamique :
pokemon[pokemon['HP'] == pokemon['HP'].max()]


Out[19]:
# Name Type 1 Type 2 Total HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary
121 113 Chansey Normal NaN 450 250 5 5 35 105 50 1 False

In [20]:
# On affiche un graphique HP/Attack :
pokemon.plot(x='HP', y='Attack', kind='scatter')
# On indique quelle mesure on désire pour l'axe "x" et "y" ainsi que le type de graphique


Out[20]:
<matplotlib.axes._subplots.AxesSubplot at 0x117702ad0>

Si l'on souhaite regarder plus de 2 mesures, on utilise ".boxplot()" de Seaborn :


In [21]:
sns.boxplot(data=pokemon)


Out[21]:
<matplotlib.axes._subplots.AxesSubplot at 0x1173c5c10>

Le problème ici c'est que Total est beaucoup plus grand que les autres mesures. De plus "#" ne sert pas à grand chose non plus

On va donc sélection uniquement les colonnes qui sont interessantes ('HP', 'Attack', 'Defense', 'Sp. Atk', 'Sp. Def','Speed')


In [22]:
sns.boxplot(data=pokemon[['HP', 'Attack', 'Defense', 'Sp. Atk', 'Sp. Def','Speed']])


Out[22]:
<matplotlib.axes._subplots.AxesSubplot at 0x117bb8650>

On retrouve notre "Chansey" tout en haut sur la variable "HP"


In [23]:
pokemon.describe()


Out[23]:
# Total HP Attack Defense Sp. Atk Sp. Def Speed Generation
count 166.000000 166.000000 166.000000 166.000000 166.000000 166.000000 166.000000 166.000000 166.0
mean 75.819277 426.813253 65.819277 76.638554 70.861446 71.819277 69.090361 72.584337 1.0
std 45.153246 115.878076 28.153968 30.744727 28.641336 34.439106 25.505275 29.675857 0.0
min 1.000000 195.000000 10.000000 5.000000 5.000000 15.000000 20.000000 15.000000 1.0
25% 36.250000 325.000000 46.500000 55.000000 50.000000 45.000000 50.000000 50.000000 1.0
50% 76.500000 436.500000 62.000000 75.000000 66.000000 65.000000 70.000000 70.000000 1.0
75% 115.000000 500.000000 80.000000 95.000000 85.000000 95.000000 85.000000 92.250000 1.0
max 151.000000 780.000000 250.000000 190.000000 180.000000 194.000000 130.000000 150.000000 1.0

Maintenant on va créer de nouvelle mesures

l'Attack et la Defence doivent jouer un grand role (avis aux pro-gamer Pokemon GO !)

Les additionner nous permettrais d'avoir une nouvelle vision sur nos pokémons


In [24]:
pokemon['Att_Def'] = pokemon['Attack'] + pokemon['Defense']


/Users/babou/anaconda/lib/python2.7/site-packages/ipykernel/__main__.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  if __name__ == '__main__':

In [25]:
pokemon.head()


Out[25]:
# Name Type 1 Type 2 Total HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary Att_Def
0 1 Bulbasaur Grass Poison 318 45 49 49 65 65 45 1 False 98
1 2 Ivysaur Grass Poison 405 60 62 63 80 80 60 1 False 125
2 3 Venusaur Grass Poison 525 80 82 83 100 100 80 1 False 165
3 3 VenusaurMega Venusaur Grass Poison 625 80 100 123 122 120 80 1 False 223
4 4 Charmander Fire NaN 309 39 52 43 60 50 65 1 False 95

In [26]:
pokemon['my_def'] = pokemon['HP'] + pokemon['Defense']


/Users/babou/anaconda/lib/python2.7/site-packages/ipykernel/__main__.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  if __name__ == '__main__':

In [27]:
pokemon.plot(x='my_def', y='Att_Def', kind='scatter')


Out[27]:
<matplotlib.axes._subplots.AxesSubplot at 0x117bf5210>

In [29]:
#pokemon.head()

Un message en rouge (warning) apparait , don't worry. Pandas vous indique que le DataFrame pokemon provient d'un autre DataFrame (data) et que ces 2 DataFrame n'aurons plus la même structure.


In [30]:
sns.boxplot(pokemon.Att_Def)


Out[30]:
<matplotlib.axes._subplots.AxesSubplot at 0x11801ae50>

Il y a un point particulier a plus de 280 ;)


In [31]:
pokemon[pokemon.Att_Def >= 280]


Out[31]:
# Name Type 1 Type 2 Total HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary Att_Def my_def
163 150 MewtwoMega Mewtwo X Psychic Fighting 780 106 190 100 154 100 130 1 True 290 206

In [32]:
pokemon.sort_values('Att_Def', ascending=0).head(8)


Out[32]:
# Name Type 1 Type 2 Total HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary Att_Def my_def
163 150 MewtwoMega Mewtwo X Psychic Fighting 780 106 190 100 154 100 130 1 True 290 206
137 127 PinsirMega Pinsir Bug Flying 600 65 155 120 65 90 105 1 False 275 185
98 91 Cloyster Water Ice 525 50 95 180 85 45 70 1 False 275 230
141 130 GyaradosMega Gyarados Water Dark 640 95 155 109 70 130 81 1 False 264 204
87 80 SlowbroMega Slowbro Water Psychic 590 95 75 180 130 80 30 1 False 255 275
82 76 Golem Rock Ground 495 80 120 130 55 65 45 1 False 250 210
120 112 Rhydon Ground Rock 485 105 130 120 45 45 40 1 False 250 225
107 99 Kingler Water NaN 475 55 130 115 50 50 75 1 False 245 170

In [33]:
Image(url="http://i.giphy.com/gPjzE0ivYud5C.gif")


Out[33]:

Amuser vous à faire des graphique grâce à la fonction de Seaborn ".lmplot(...)"

Cette fonction prend en argument (pour plus de détail tapez "sns.lmplot?" ) :

  • x : Mesure sur l'axe "x" --> x=...
  • y : Mesure sur l'axe "y" --> y=...
  • data : Nom de la variable du DataFrame --> data=...

In [37]:
sns.lmplot(x='Sp. Atk', y='Sp. Def', data=pokemon)


Out[37]:
<seaborn.axisgrid.FacetGrid at 0x1183c5610>

Seaborn fait automatiquement une regression sur ces 2 mesures. C'est à dire qu'il essait de tiret un trait qui va minimiser l'erreur avec les points


In [38]:
pokemon[(pokemon['Sp. Atk'] >= 180)]


Out[38]:
# Name Type 1 Type 2 Total HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary Att_Def my_def
164 150 MewtwoMega Mewtwo Y Psychic NaN 780 106 150 70 194 120 140 1 True 220 176

Les points qui sont au dessus peuvent etre considérés comme supérieur et sont en dessous comme inférieur.

Regardons un peu les types de pokemon maintenant :


In [39]:
# De façon écrite :
pokemon['Type 1'].value_counts()


Out[39]:
Water       31
Normal      24
Poison      14
Bug         14
Fire        14
Grass       13
Psychic     11
Rock        10
Electric     9
Ground       8
Fighting     7
Ghost        4
Dragon       3
Fairy        2
Ice          2
Name: Type 1, dtype: int64

In [40]:
# par un graphique :
sns.countplot(pokemon['Type 1'])


Out[40]:
<matplotlib.axes._subplots.AxesSubplot at 0x1182a8c50>

Le graphique est un peu trop petit et on ne peux pas distinger les types


In [41]:
# On prend l'ensemble des type 1 possible en valeurs
list_type_1 = pokemon['Type 1'].unique()        # Comme une liste de toutes les valeurs possible de "Type 1"

# Un peu de custom dans nos graphiques :
plt.figure(figsize=(12,8))                       # Tu vas créer un graphique de taille un peu plus grand
graph = sns.countplot(pokemon['Type 1'])            # Notre graphique que l'on met en variable
graph.set_xticklabels(list_type_1, rotation=20)     # On dit qu'il faut faire une rotation de nos valeur "Type 1"


Out[41]:
[<matplotlib.text.Text at 0x11907ee90>,
 <matplotlib.text.Text at 0x11909cf50>,
 <matplotlib.text.Text at 0x119102b50>,
 <matplotlib.text.Text at 0x11910f310>,
 <matplotlib.text.Text at 0x11910fa90>,
 <matplotlib.text.Text at 0x119118250>,
 <matplotlib.text.Text at 0x1191189d0>,
 <matplotlib.text.Text at 0x119123190>,
 <matplotlib.text.Text at 0x119123910>,
 <matplotlib.text.Text at 0x11912b0d0>,
 <matplotlib.text.Text at 0x11912b850>,
 <matplotlib.text.Text at 0x11912bfd0>,
 <matplotlib.text.Text at 0x119137790>,
 <matplotlib.text.Text at 0x119137f10>,
 <matplotlib.text.Text at 0x11913f6d0>]

De type 2 :


In [42]:
# Vous pouvez copier / coller le code au dessous en changeant "Type 1" -> "Type 2"

# On prend l'ensemble des type 1 possible en valeurs
list_type_2 = pokemon['Type 2'].unique()        # Comme une liste de toutes les valeurs possible de "Type 1"

# Un peu de custom dans nos graphiques :
plt.figure(figsize=(12,8));                         # Tu vas créer un graphique de taille un peu plus grand
graph = sns.countplot(pokemon['Type 2'])            # Notre graphique que l'on met en variable
graph.set_xticklabels(list_type_2, rotation=20)     # O


Out[42]:
[<matplotlib.text.Text at 0x1195b8050>,
 <matplotlib.text.Text at 0x1195d5b10>,
 <matplotlib.text.Text at 0x11966ca90>,
 <matplotlib.text.Text at 0x119676250>,
 <matplotlib.text.Text at 0x1196769d0>,
 <matplotlib.text.Text at 0x119682190>,
 <matplotlib.text.Text at 0x119682910>,
 <matplotlib.text.Text at 0x1196890d0>,
 <matplotlib.text.Text at 0x119689850>,
 <matplotlib.text.Text at 0x119689fd0>,
 <matplotlib.text.Text at 0x119693790>,
 <matplotlib.text.Text at 0x119693f10>,
 <matplotlib.text.Text at 0x11969f6d0>]

Utilisation de "groupby“ afin de regrouper les données sur des valeurs :

On reprend donc nos DataFrame "data" pour analyser l'évolution des Generation


In [64]:
generation = data.groupby('Generation').mean()
generation


Out[64]:
# Total HP Attack Defense Sp. Atk Sp. Def Speed Legendary
Generation
1 75.819277 426.813253 65.819277 76.638554 70.861446 71.819277 69.090361 72.584337 0.036145
2 202.283019 418.283019 71.207547 72.028302 73.386792 65.943396 73.905660 61.811321 0.047170
3 321.968750 436.225000 66.543750 81.625000 74.100000 75.806250 71.225000 66.925000 0.112500
4 442.446281 459.016529 73.082645 82.867769 78.132231 76.404959 77.190083 71.338843 0.107438
5 574.272727 434.987879 71.787879 82.066667 72.327273 71.987879 68.739394 68.078788 0.090909
6 688.012195 436.378049 68.268293 75.804878 76.682927 74.292683 74.890244 66.439024 0.097561

On souhaite supprimer les mesures "#", "Total" et "Legendary" qui ne servent pas à grand chose ici...


In [65]:
# Help fonction drop
#generation.drop?

In [66]:
generation = generation.drop(['#', 'Total', 'Legendary'], axis=1)  # axis = 1 sont les colonnes / 0 sont les lignes

In [67]:
generation


Out[67]:
HP Attack Defense Sp. Atk Sp. Def Speed
Generation
1 65.819277 76.638554 70.861446 71.819277 69.090361 72.584337
2 71.207547 72.028302 73.386792 65.943396 73.905660 61.811321
3 66.543750 81.625000 74.100000 75.806250 71.225000 66.925000
4 73.082645 82.867769 78.132231 76.404959 77.190083 71.338843
5 71.787879 82.066667 72.327273 71.987879 68.739394 68.078788
6 68.268293 75.804878 76.682927 74.292683 74.890244 66.439024

In [68]:
generation.plot(figsize=(12, 8))  # figsize permet de choisir la taille du graphique


Out[68]:
<matplotlib.axes._subplots.AxesSubplot at 0x11a8152d0>

Vous pouvez changer l'analyse en utilisant autre chose que la moyenne ".mean()" et regarder comment cela évolue à travers les différentes générations de pokémon


In [ ]: