Pokemon Comparisons

This project is used to compare pokemon to see which generations have the strongest, whether there is a correlation between attack power and defense power in pokemon from all generations, and to break each pokemon down by type to see which type is the strongest.

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

     Defense  Sp. Atk  Sp. Def  Speed  Generation  Legendary  
0         49       65       65     45           1      False  
1         63       80       80     60           1      False  
2         83      100      100     80           1      False  
3        123      122      120     80           1      False  
4         43       60       50     65           1      False  
5         58       80       65     80           1      False  
6         78      109       85    100           1      False  
7        111      130       85    100           1      False  
8         78      159      115    100           1      False  
9         65       50       64     43           1      False  
10        80       65       80     58           1      False  
11       100       85      105     78           1      False  
12       120      135      115     78           1      False  
13        35       20       20     45           1      False  
14        55       25       25     30           1      False  
15        50       90       80     70           1      False  
16        30       20       20     50           1      False  
17        50       25       25     35           1      False  
18        40       45       80     75           1      False  
19        40       15       80    145           1      False  
20        40       35       35     56           1      False  
21        55       50       50     71           1      False  
22        75       70       70    101           1      False  
23        80      135       80    121           1      False  
24        35       25       35     72           1      False  
25        60       50       70     97           1      False  
26        30       31       31     70           1      False  
27        65       61       61    100           1      False  
28        44       40       54     55           1      False  
29        69       65       79     80           1      False  
..       ...      ...      ...    ...         ...        ...  
770       65      110      130     60           6      False  
771       75       74       63    118           6      False  
772       57       81       67    101           6      False  
773      150       50      150     50           6      False  
774       35       55       75     40           6      False  
775       53       83      113     60           6      False  
776       70      110      150     80           6      False  
777       91       80       87     75           6      False  
778       48       50       60     38           6      False  
779       76       65       82     56           6      False  
780       70       44       55     51           6      False  
781       70       44       55     56           6      False  
782       70       44       55     46           6      False  
783       70       44       55     41           6      False  
784      122       58       75     84           6      False  
785      122       58       75     99           6      False  
786      122       58       75     69           6      False  
787      122       58       75     54           6      False  
788       85       32       35     28           6      False  
789      184       44       46     28           6      False  
790       35       45       40     55           6      False  
791       80       97       80    123           6      False  
792       95      131       98     99           6       True  
793       95      131       98     99           6       True  
794      121       81       95     95           6       True  
795      150      100      150     50           6       True  
796      110      160      110    110           6       True  
797       60      150      130     70           6       True  
798       60      170      130     80           6       True  
799      120      130       90     70           6       True  

[800 rows x 13 columns]

Comparing Attack and Defense Power Across Generations

In [2]:
gen1 = df[df['Generation'] == 1]
gen2 = df[df['Generation'] == 2]
gen3 = df[df['Generation'] == 3]
gen4 = df[df['Generation'] == 4]
gen5 = df[df['Generation'] == 5]
gen6 = df[df['Generation'] == 6]

plt.figure(figsize=(20, 10))

plt.subplot(1, 2, 1)
plt.hist(gen1['Attack'], normed=True, color='blue', alpha=.5)
plt.hist(gen2['Attack'], normed=True, color='red', alpha=.5) 
plt.hist(gen3['Attack'], normed=True, color='yellow', alpha=.5)
plt.hist(gen4['Attack'], normed=True, color='green', alpha=.5)
plt.hist(gen5['Attack'], normed=True, color='orange', alpha=.5)
plt.hist(gen6['Attack'], normed=True, color='pink', alpha=.5)
plt.title('Attack Power Between Generations')
plt.xlabel('Attack Power')

plt.subplot(1, 2, 2)
plt.hist(gen1['Defense'], normed=True, color='blue', alpha=.5)
plt.hist(gen2['Defense'], normed=True, color='red', alpha=.5) 
plt.hist(gen3['Defense'], normed=True, color='yellow', alpha=.5)
plt.hist(gen4['Defense'], normed=True, color='green', alpha=.5)
plt.hist(gen5['Defense'], normed=True, color='orange', alpha=.5)
plt.hist(gen6['Defense'], normed=True, color='pink', alpha=.5)
plt.title('Defense Power Between Generations')
plt.xlabel('Defense Power')

plt.show()

Comparing Pokemon Attack Power and Defense Power

In [3]:
plt.scatter(x = df['Attack'], y = df['Defense'])
plt.xlabel('Attack Power')
plt.ylabel('Defense Power')
plt.title('Pokemon Attack and Defense Power Comparison')
plt.show()

Strongest Pokemon Type

In [4]:
groupByType1 = df.groupby('Type 1')

typesOfPokemon = groupByType1.groups.keys()
numOfPokemonInType = groupByType1.size()
y_pos = np.arange(len(numOfPokemonInType))

plt.figure(figsize=(20,10))
plt.bar(y_pos, numOfPokemonInType, align='center', alpha=0.5)
plt.xticks(y_pos, typesOfPokemon)
plt.ylabel('# of Pokemon in Type')
plt.title('Type of Pokemon')
 
plt.show()
In [5]:
groupByType1.mean().loc[:, ['Attack', 'Defense', 'HP']].sort_values('Attack')
Out[5]:
Attack Defense HP
Type 1
Fairy 61.529412 65.705882 74.117647
Electric 69.090909 66.295455 59.795455
Bug 70.971014 70.724638 56.884058
Psychic 71.456140 67.684211 70.631579
Ice 72.750000 71.416667 72.000000
Grass 73.214286 70.800000 67.271429
Normal 73.469388 59.846939 77.275510
Ghost 73.781250 81.187500 64.437500
Water 74.151786 72.946429 72.062500
Poison 74.678571 68.821429 67.250000
Flying 78.750000 66.250000 70.750000
Fire 84.769231 67.769231 69.903846
Dark 88.387097 70.225806 66.806452
Steel 92.703704 126.370370 65.222222
Rock 92.863636 100.795455 65.363636
Ground 95.750000 84.843750 73.781250
Fighting 96.777778 65.925926 69.851852
Dragon 112.125000 86.375000 83.312500