Visualizing datasets with Seaborn and Pandas in Python

Game of Thrones

import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv("battles.csv")
#print(df.dtypes)
#print(df.head())

sns.set_style("whitegrid")
#example_one = sns.barplot(x="year",y="major_death",data=df)

example_two = sns.factorplot(x="attacker_size",y="defender_size", hue="attacker_outcome",data=df,kind="bar",palette="muted",size=6)
plt.xticks(rotation=70)
plt.rcParams["xtick.labelsize"] = 9
plt.show()

Seaborn Games of Thrones Outcome

Bivariate

import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="white")

# Generate a random correlated bivariate dataset
rs = np.random.RandomState(5)
mean = [0, 0]
cov = [(1, .5), (.5, 1)]
x1, x2 = rs.multivariate_normal(mean, cov, 500).T
x1 = pd.Series(x1, name="$X_1$")
x2 = pd.Series(x2, name="$X_2$")

# Show the joint distribution using kernel density estimation
g = sns.jointplot(x1, x2, kind="kde", size=7, space=0)
plt.show()

Bivariate dataset in joint distribution using kernel density estimation (kde)

Flights

import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

example_four = sns.load_dataset("flights")
example_four = example_four.pivot('month','year','passengers')
display_four = sns.heatmap(example_four)
plt.show()

Seaborn Heatmap Flights

display_four = sns.heatmap(example_four,annot=True,fmt='d')

Seaborn Heatmap Flights

Pokemon

import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
df = pd.read_csv("Pokemon.csv")
sns.swarmplot(x="Type 1",y="Attack",data=df)
plt.xticks(rotation=70)
plt.show()

Seaborn Swarmplot Pokemon