Description

This is an example tutorial to use my module bhishan for the plotly extension for pandas.

Imports

In [1]:
import numpy as np
import pandas as pd
import seaborn as sns
import bhishan
from bhishan import bp
import matplotlib.pyplot as plt

%load_ext autoreload
%load_ext watermark

%autoreload 2
%watermark -a "Bhishan Poudel" -d -v -m
%watermark -iv
Bhishan Poudel 2020-09-28 

CPython 3.7.7
IPython 7.18.1

compiler   : Clang 4.0.1 (tags/RELEASE_401/final)
system     : Darwin
release    : 19.6.0
machine    : x86_64
processor  : i386
CPU cores  : 4
interpreter: 64bit
json     2.0.9
numpy    1.18.4
autopep8 1.5.2
seaborn  0.11.0
bhishan  0.3.1
pandas   1.1.0

Load the data

In [2]:
# print(sns.get_dataset_names())
In [3]:
df = sns.load_dataset('titanic')

Boxplots

In [4]:
df.bp.plot_boxplot_cats_num(['pclass','sex'],'age',show=True)

Count plots

In [5]:
df.bp.countplot(['pclass','parch'],1,2)
In [6]:
df.bp.plot_count_cat('pclass',show=True)

regplot

In [7]:
df = sns.load_dataset('titanic')
df.head(2)
Out[7]:
survived pclass sex age sibsp parch fare embarked class who adult_male deck embark_town alive alone
0 0 3 male 22.0 1 0 7.2500 S Third man True NaN Southampton no False
1 1 1 female 38.0 1 0 71.2833 C First woman False C Cherbourg yes False
In [8]:
df = sns.load_dataset('titanic')
cols1 = ['fare','age']
cols2 = ['age','fare']
target = 'survived'
df.bp.regplot_binn(cols1,cols2,target,1,2)
In [9]:
sns.lmplot(x='age',y='fare',data=df,hue='survived')
Out[9]:
<seaborn.axisgrid.FacetGrid at 0x7f9de1d1d8d0>

Pareto Chart

In [10]:
tips = sns.load_dataset('tips')
tips.bp.plot_pareto('size',thr=90)
In [ ]: