Notebook

Using Pandas for Analyzing Data - Visualization

In [5]:
%matplotlib inline
import numpy as np
import pandas as pd

Read the csv file of your choice

In [6]:
ver=pd.read_csv("ver.csv")

Plot counts of a specified column using Pandas

In [4]:
ver.loan_purpose_name.value_counts().plot(kind='barh')
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f84a288acd0>

Bar plot of median values

In [8]:
ver.groupby('agency_abbr')['applicant_income_000s'].agg(np.median).plot(kind = 'bar')
Out[8]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f3481f14ed0>

Box plot example

In [12]:
g = sns.factorplot("loan_purpose_name", "loan_amount_000s", "agency_abbr", ver, kind="box",                        
                   palette="PRGn",aspect=2.25)
g.set(ylim=(0, 600))
Out[12]:
<seaborn.axisgrid.FacetGrid at 0x7f84a2cf8950>

Bar plot example

In [11]:
sns.factorplot("loan_purpose_name", data=ver, hue="agency_abbr",size=3,aspect=2)
Out[11]:
<seaborn.axisgrid.FacetGrid at 0x7f3481b241d0>

Another bar plot example

In [12]:
sns.factorplot("loan_purpose_name", "loan_amount_000s", data=ver, palette="BuPu_d")
Out[12]:
<seaborn.axisgrid.FacetGrid at 0x7f3481b24110>

Violin plot example

In [13]:
sns.violinplot(ver["loan_amount_000s"], ver["loan_purpose_name"], color="BuPu_d").set_ylim(0, 800)
sns.despine(left=True);

Violin plot using log amount

In [14]:
sns.violinplot(ver["logloanamt"], ver["loan_purpose_name"], color="BuPu_d").set_ylim(0, 10)
sns.despine(left=True);

Regression plot

In [17]:
sns.regplot("logloanamt", "logincome", data=ver, robust=True, ci=95, color="seagreen")
sns.despine();

Bar plot of median values

In [16]:
sns.factorplot("agency_abbr", "loan_amount_000s", data=ver, palette="PuBu_d", estimator=np.median);

Bar plot example

In [8]:
sns.factorplot("loan_purpose_name", data=ver, hue="action_taken_name");