In [1]:
import numpy as np
import pandas as pd
In [2]:
import bokeh as bk
from bokeh.io import output_notebook,show,gridplot
output_notebook()
In [3]:
print np.__version__
print pd.__version__
print bk.__version__
print bk.__file__
In [4]:
np.random.seed(1234509876)
signal = np.random.normal(0.5,0.1,900)
instr = np.random.poisson(0.5,100)
sample = np.concatenate((signal,instr[instr>0]),axis=0)
np.random.shuffle(sample)
df = pd.DataFrame({'sample':sample})
df.describe()
Out[4]:
In [5]:
from bokeh.charts import Histogram
p = Histogram(df,'sample')
show(p)
Out[5]:
In [6]:
nbins = 10
bins = np.linspace(0,1,nbins)
df['bins'] = pd.cut(df['sample'],bins)
df['quantil'] = pd.qcut(df['sample'],nbins)
print df.describe(include='all')
hnan = df.isnull().any().values
nnan = df.isnull().sum().values
_f = '{:<10}\t{}\t{:>10}'
#print _f.format('\n','Has NaN?','How many?')
#for i,col in enumerate(df.columns):
# print _f.format(col,hnan[i],nnan[i])
In [7]:
print df.groupby('bins').describe()
In [8]:
from bokeh.charts import BoxPlot
p = BoxPlot(df,values='sample',label='quantil')
show(p)
Out[8]:
In [9]:
brandt = None
In [10]:
import matplotlib.pyplot as plt
ret1 = df.boxplot(column='sample',by='bins',grid=False)
plt.ylim([0,1.1])
plt.xticks(rotation=90)
fig1 = plt.gcf()
from bokeh import mpl
show(mpl.to_bokeh())
Out[10]:
In [11]:
%matplotlib inline
import matplotlib.pyplot as plt
ret2 = df.boxplot(column='sample',by='bins',grid=False)
plt.ylim([0,1.1])
plt.xticks(rotation=90)
fig2 = plt.gcf()
plt.show()
In [12]:
import seaborn as sns
print sns.__version__
from bokeh import mpl
from bokeh.io import output_notebook, show
output_notebook()
iris = sns.load_dataset("iris")
sns.violinplot(iris.species,iris.sepal_length)
show(mpl.to_bokeh())
Out[12]:
In [13]:
from bokeh.plotting import output_file, show
from bokeh.sampledata.iris import flowers
import matplotlib
matplotlib.use('TKAgg')
from bokeh import mpl
flowers.boxplot(column='sepal_length', by='species')
show(mpl.to_bokeh())
Out[13]:
In [14]:
#print iris.groupby('species').describe()
#print flowers.groupby('species').describe()
(flowers == iris).all()
Out[14]:
In [ ]: