Bokeh: ValueError: Out of range float values are not JSON compliant

I had the same error and I debugged the problem: I had NaN values in my plotted dataset and bokeh‘s serialize_json() function (in /core/json_encoder.py) does not allow NaN values (I don’t know why…). In the return part of this function there is the allow_nan=False argument in json.dumps() :(( The problem occurs only at the io part of bokeh process when the output file is generated (it calls the above serialize_json() function).

So you have to replace NaN values in your dataframe, eg.:

df = df.fillna('')

Nice day! 🙂

Leave a Comment

tech