Description

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

Imports

In [6]:
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
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload
The watermark extension is already loaded. To reload it, use:
  %reload_ext watermark
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
seaborn  0.11.0
autopep8 1.5.2
numpy    1.18.4
json     2.0.9

Using plotly api in module bhishan

In [2]:
ts = pd.date_range(start='1/1/2018',
                    end='2/1/2019',freq='H')
target = np.random.choice([0,1],size=len(ts))
df_ts = pd.DataFrame({'date': ts, 'target': target})
df_ts.head()
Out[2]:
date target
0 2018-01-01 00:00:00 1
1 2018-01-01 01:00:00 0
2 2018-01-01 02:00:00 1
3 2018-01-01 03:00:00 0
4 2018-01-01 04:00:00 0
In [3]:
df_ts.bp.plot_date_cat('date','target')
In [4]:
ts_small = pd.date_range(start='1/1/2018',
                    end='2/1/2018',freq='H')
target = np.random.choice([0,1,2],size=len(ts_small))
df_ts_small = pd.DataFrame({'date': ts_small, 'target': target})

df_ts_small.bp.plot_daily_cat('date','target')
In [ ]: