Hi there,
I had some issues when trying to visualise some data using the Bar() class, using information extracted from a Pandas data frame which contained NaNs.
Just thought I’d flag this as it tripped me up with a silent failure in my web app (ended up with a completely blank canvas as none of my plots rendered). Here’s some very brief reproduction code to what I am assuming is the basic issue, using a Bokeh example. It’s a lovely helper class, but I guess my feature request (if possible) would be to explicitly error so people can quickly figure out where the problem is.
Whaddya think?
import numpy
from collections import OrderedDict
import pandas as pd
from bokeh.charts import Bar, output_file, show
from bokeh.sampledata.olympics2014 import data
df = pd.io.json.json_normalize(data[‘data’])
filter by countries with at least one medal and sort
df = df[df[‘medals.total’] > 0]
df = df.sort(“medals.total”, ascending=False)
df[‘medals.bronze’][65] = numpy.nan
get the countries and we group the data by medal type
countries = df.abbr.values.tolist()
gold = df[‘medals.gold’].astype(float).values
silver = df[‘medals.silver’].astype(float).values
bronze = df[‘medals.bronze’].astype(float).values
build a dict containing the grouped data
medals = OrderedDict(bronze=bronze, silver=silver, gold=gold)
output_file(“stacked_bar.html”)
bar = Bar(medals, countries, title=“Stacked bars”, stacked=True)
show(bar)
