TypeError: object is not JSON serializable

Hi,

I am building several plots with DataColumnSources made from a pandas data frame with the following structure:

a.df.info()

<class ‘pandas.core.frame.DataFrame’>

DatetimeIndex: 2599 entries, 2005-02-16 to 2015-08-26

Data columns (total 8 columns):

col1 2599 non-null float64

col2 2599 non-null float64

col3 2599 non-null float64

col4 2599 non-null float64

col5 2599 non-null float64

col6 2599 non-null float64

col7 2599 non-null float64

col8 2599 non-null float64

the plots are collected in a dictionary and bokeh.embed.components is called (just like the embed_multiple.py example) then they are used in a render_template flask call (as a return of a route function).

I get the following error: “TypeError: <plotters.IHPlots object at 0x107b669b0> is not JSON serializable”

Is it the datetime64 or float64 that (still) create issues (I found a github issue about int64)?

Thanks

PS: the ultimate goal is not to call render_template but to pass them back to a JQuery request to avoid rendering the whole page.

Hi Alex,

I’m guessing that you’ve made your column data source using a data frame that includes a column of “plotters.IHPlots” objects - which aren’t serializable.

If this isn’t it, then you need to provide more information - a copy of your data and code.

Best,

Sarah Bird

···

On Sun, Sep 6, 2015 at 2:37 AM, Alexandre Avanian [email protected] wrote:

Hi,

I am building several plots with DataColumnSources made from a pandas data frame with the following structure:

a.df.info()

<class ‘pandas.core.frame.DataFrame’>

DatetimeIndex: 2599 entries, 2005-02-16 to 2015-08-26

Data columns (total 8 columns):

col1 2599 non-null float64

col2 2599 non-null float64

col3 2599 non-null float64

col4 2599 non-null float64

col5 2599 non-null float64

col6 2599 non-null float64

col7 2599 non-null float64

col8 2599 non-null float64

the plots are collected in a dictionary and bokeh.embed.components is called (just like the embed_multiple.py example) then they are used in a render_template flask call (as a return of a route function).

I get the following error: “TypeError: <plotters.IHPlots object at 0x107b669b0> is not JSON serializable”

Is it the datetime64 or float64 that (still) create issues (I found a github issue about int64)?

Thanks

PS: the ultimate goal is not to call render_template but to pass them back to a JQuery request to avoid rendering the whole page.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3c203de2-0806-4c2d-9992-9193e43b1169%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

You make a good point that there is no reason for the render_template to even know about IHPlots. It’s a class that contains the data, plot parameters and builds the plots, export the script/divs. There is no instance of it attached to or contained by anything I pass to the plots

Following that, I took the embed_multiple.py example, replace the plots by my input and it worked so I realized I was attaching the object to the session and somehow this must be jsoned between views, if I del that entry from the session, the error went away. Nothing to do with Bokeh.

Sorry about that and thanks

···

On Sunday, September 6, 2015 at 5:52:23 PM UTC+8, Sarah Bird wrote:

Hi Alex,

I’m guessing that you’ve made your column data source using a data frame that includes a column of “plotters.IHPlots” objects - which aren’t serializable.

If this isn’t it, then you need to provide more information - a copy of your data and code.

Best,

Sarah Bird

On Sun, Sep 6, 2015 at 2:37 AM, Alexandre Avanian [email protected] wrote:

Hi,

I am building several plots with DataColumnSources made from a pandas data frame with the following structure:

a.df.info()

<class ‘pandas.core.frame.DataFrame’>

DatetimeIndex: 2599 entries, 2005-02-16 to 2015-08-26

Data columns (total 8 columns):

col1 2599 non-null float64

col2 2599 non-null float64

col3 2599 non-null float64

col4 2599 non-null float64

col5 2599 non-null float64

col6 2599 non-null float64

col7 2599 non-null float64

col8 2599 non-null float64

the plots are collected in a dictionary and bokeh.embed.components is called (just like the embed_multiple.py example) then they are used in a render_template flask call (as a return of a route function).

I get the following error: “TypeError: <plotters.IHPlots object at 0x107b669b0> is not JSON serializable”

Is it the datetime64 or float64 that (still) create issues (I found a github issue about int64)?

Thanks

PS: the ultimate goal is not to call render_template but to pass them back to a JQuery request to avoid rendering the whole page.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3c203de2-0806-4c2d-9992-9193e43b1169%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.