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
pandas   1.1.0
bhishan  0.3.1
autopep8 1.5.2
seaborn  0.11.0
json     2.0.9
numpy    1.18.4

Load data

In [2]:
titanic = sns.load_dataset('titanic')
titanic.head()
Out[2]:
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
2 1 3 female 26.0 0 0 7.9250 S Third woman False NaN Southampton yes True
3 1 1 female 35.0 1 0 53.1000 S First woman False C Southampton yes False
4 0 3 male 35.0 0 0 8.0500 S Third man True NaN Southampton no True

Numerical and Categorical Plots

In [3]:
df = titanic
In [4]:
# df.bp.plot_num('age',print_=True,ms='seaborn-darkgrid')
df.bp.plot_num(num='age',print_=True,ms='dark_background')
     count       mean        std   min     25%   50%   75%   max
age  714.0  29.699118  14.526497  0.42  20.125  28.0  38.0  80.0
In [5]:
df.bp.plot_cat('pclass',ms=-1)
In [6]:
df.bp.plot_num_num('age','fare',xticks1=range(0,90,10),ms=-1,
                   xticks2=range(0,600,50),rot=90,figsize=(12,12))
In [7]:
df.bp.plot_num_cat('pclass','sex',save=True,show=True)
In [8]:
df.bp.plot_cat_num('pclass','age',save=True,show=True,ms='fast')
In [9]:
df.bp.plot_cat_cat('pclass','survived',save=True,show=True,ms=-1)
==================================================
Feature: **pclass**
Overall Count: 
    3: 55.11%
    1: 24.24%
    2: 20.65%

Total  **survived_1** distribution:
    1: 39.77%
    3: 34.8%
    2: 25.44%

Per pclass  **survived_1** distribution:
    1: 62.96%
    2: 47.28%
    3: 24.24%
In [ ]: