# Import libraries and DataFrame
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from pandas import DataFrame, Series
# Read the data from pokeman.csv into a DataFrame using pandas read_csv()
# Print out the first 6 lines of data using .head
df = pd.read_csv("pokeman.csv")
df.head(6)
#int64
Nameobject
0
1
Bulbasaur
1
2
Ivysaur
2
3
Venusaur
3
4
Charmander
4
5
Charmeleon
5
6
Charizard
# print out the data types of all features using .dtypes (no parentheses)
df.dtypes
# print out the column names using .columns
df.columns
# Create a pandas Series for the feature Speed; print out type
df["Speed"]
# Create a NumPy array for the feature Speed (use.values) ; print out type
spd = df.Speed.values
print(spd)
[ 45 60 80 65 80 100 43 58 78 45 30 70 50 35 75 56 71 101
72 97 70 100 55 80 90 110 40 65 41 56 76 50 65 85 35 60
65 100 20 45 55 90 30 40 50 25 30 45 90 95 120 90 115 55
85 70 95 60 95 90 90 70 90 105 120 35 45 55 40 55 70 70
100 20 35 45 90 105 15 30 45 70 60 75 100 45 70 25 50 40
70 80 95 110 70 42 67 50 75 100 140 40 55 35 45 87 76 30
35 60 25 40 50 60 90 60 85 63 68 85 115 90 105 95 105 93
85 110 80 81 60 48 55 65 130 65 40 35 55 55 80 130 30 85
100 90 50 70 80 130 100]
# Make 1D NumPy arrays from the features Attack and Defense and do a scatter plot
# using matplotlib
Att = df.Attack.values
Def = df.Defense.values
plt.scatter(Att, Def)
plt.xlabel("Attack")
plt.ylabel("Defense")
plt.title("Attack vs. Defense")
# Create a new DataFrame "df_mod" which is same as original but we drop "Type 2" feature; print out to check
df_mod = df.drop(columns = ["Type 2"])
df_mod
#int64
1 - 151
Nameobject
Bulbasaur0.7%
Ivysaur0.7%
149 others98.7%
0
1
Bulbasaur
1
2
Ivysaur
2
3
Venusaur
3
4
Charmander
4
5
Charmeleon
5
6
Charizard
6
7
Squirtle
7
8
Wartortle
8
9
Blastoise
9
10
Caterpie
# Import libraries and DataFrame
#
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from pandas import DataFrame, Series
import seaborn as sns
# Read the data into a DataFrame
# Print out the first 5 lines of data
# The section instructions say the first 6 lines of data, like the first section, so I'm going with 6 just in case!
df = pd.read_csv("pokeman.csv")
df.head(6)
#int64
Nameobject
0
1
Bulbasaur
1
2
Ivysaur
2
3
Venusaur
3
4
Charmander
4
5
Charmeleon
5
6
Charizard
# Add a white grid to the background of Seaborn plots using set_style
sns.set_style("whitegrid") #Don't capitalize the W, it won't accept it!
# Make a scatter plot using Seaborn's relplot of Defense statistics (y-axis)
# vs Attacks Stats
sns.relplot(x = "Attack", y = "Defense", data = df)
# Have to be very specific unlike with previous scatter plot code
# Repeat plot in previous cell but use color to indicate Type 1 (hue = )
sns.relplot(x = "Attack", y = "Defense", data = df, hue = "Type 1")
# Just add on the hue part to the code from previous box
# Make a category plot of Defense statistics vs Type 1 (non-numerical)
# Rotation labels on x-axis for readability using plt.xticks using plt.xticks(rotation=-45)
# Category, so use catplot
# Wasn't sure what data should be on which axis so I went with what I thought made more sense
sns.catplot(x = "Type 1", y = "Defense", data = df, hue = "Type 1")
plt.xticks(rotation = -