close

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

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Bokeh: ValueError: Out of range float values are not JSON compliant in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Bokeh: ValueError: Out of range float values are not JSON compliant Error Occurs?

Today I get the following error Bokeh: ValueError: Out of range float values are not JSON compliant in python.

How To Solve Bokeh: ValueError: Out of range float values are not JSON compliant Error ?

  1. How To Solve Bokeh: ValueError: Out of range float values are not JSON compliant Error ?

    To Solve Bokeh: ValueError: Out of range float values are not JSON compliant Error NaN support will be better supported when this Pull Request to add a binary array serialization option is merged.

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

    To Solve Bokeh: ValueError: Out of range float values are not JSON compliant Error NaN support will be better supported when this Pull Request to add a binary array serialization option is merged.

Solution 1

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! 🙂

Solution 2

NaN support will be better supported when this Pull Request to add a binary array serialization option is merged. This should be available in Bokeh 0.12.4 in January 2017. Bokeh does not use allow_nan in the python JSON encoder, because that is not standard — nan and inf are not part of the official JSON specification (an egregious oversight IMO, but out of our control)

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read