import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%load_ext autoreload
%load_ext watermark
%autoreload 2
%watermark -a "Bhishan Poudel" -d -v -m
%watermark -iv
Bhishan Poudel 2021-07-11 CPython 3.7.7 IPython 7.22.0 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.2.4 numpy 1.19.5 seaborn 0.11.0
# my local library
import sys
sys.path.append("/Users/poudel/Dropbox/a00_Bhishan_Modules/")
sys.path.append("/Users/poudel/Dropbox/a00_Bhishan_Modules/bhishan")
from bhishan import bp
titanic = sns.load_dataset('titanic')
titanic.head()
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 |
df = titanic
# 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
df.bp.plot_cat('pclass',ms=-1)
df.bp.plot_num_num('age','fare',xticks1=range(0,90,10),ms=-1,
xticks2=range(0,600,50),rot=90,figsize=(12,12))
df.bp.plot_num_cat('pclass','sex',save=True,show=True)
df.bp.plot_cat_num('pclass','age',save=True,show=True,ms='fast')
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%