#!/usr/bin/env python # coding: utf-8 # # 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 get_ipython().run_line_magic('matplotlib', 'inline') df = pd.read_csv('Pokemon.csv') print(df) # ## 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')