VISUALIZING A PANDAS DATAFRAME IN SEABORN
Listing 5.35 displays the contents of pandas_seaborn.py that illustrates how to display a Pandas dataset in Seaborn.
Listing 5.35: pandas_seaborn.py
import pandas as pd
import random
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.DataFrame()
df['x'] = random.sample(range(1, 100), 25)
df['y'] = random.sample(range(1, 100), 25)
print("top five elements:")
print(df.head())
# display a density plot
#sns.kdeplot(df.y)
# display a density plot
#sns.kdeplot(df.y, df.x)
#sns.distplot(df.x)
# display a histogram
#plt.hist(df.x, alpha=.3)
#sns.rugplot(df.x)
# display a boxplot
#sns.boxplot([df.y, df.x])
# display a violin plot
#sns.violinplot([df.y, df.x])
# display a heatmap
#sns.heatmap([df.y, df.x], annot=True, fmt="d")
# display a cluster map
#sns.clustermap(df)
# display a scatterplot of the data points
sns.lmplot('x', 'y', data=df, fit_reg=False)
plt.show()
Listing...