bokeh server - how to lead data from a file

Hi,

I’m new to bokeh. I’m playing with bokeh-server and trying to build a simple app.

I want to load a pandas dataframe from a .csv file with three columns - ‘Name’, ‘timestamp’, and ‘value’.

For the visualization, I want to build something similar to the sliderApp example (http://bokeh.pydata.org/en/latest/docs/server_gallery/sliders_server.html) with one plot of ‘timestamp’ versus ‘value’ columns in the data frame. I want to have a single text input field (like the ‘title’ box in the slider example) where a user can input a name. I want to filter the pandas data frame where value in ‘Name’ column is equal to the user-input and plot only the timestamps and values corresponding to that name.

I took the slider app code (https://github.com/bokeh/bokeh/blob/master/examples/app/sliders_applet/sliders_app.py) as a template and tried to load the data frame from the file into a separate obj.df field in the “create” function. But apparently that doesn’t work - I get this error:

AttributeError: unexpected attribute ‘df’ to SlidersApp, possible attributes are children, disabled, height, inputs, name, plot, session, source, tags, text or width

How do I load data from a local file?

Thanks!

MS

Can you post some code?

Generally, if you want to have a property on an App, you need to specify it - e.g. https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_app.py#L32

Here I declare all the things that are going to be attached to my App and what type of things they’re going to be. You can see that I’ve got a number of instances of ColumnDataSource attached. These could have been populated from a local csv (via pd.read_csv), although in my case they came from a db.

However, there is a workaround. If you were to use obj._df I believe that the properties checking would be ignored and you could attach a dataframe to it. But that’s probably not the safest move.

I’m pretty sure that you can’t have Instance(DataFrame) as a valid property though, only Instance(ColumnDataSource).

Hope this helps,

Bird

···

On Thu, May 7, 2015 at 6:19 PM, M S [email protected] wrote:

Hi,

I’m new to bokeh. I’m playing with bokeh-server and trying to build a simple app.

I want to load a pandas dataframe from a .csv file with three columns - ‘Name’, ‘timestamp’, and ‘value’.

For the visualization, I want to build something similar to the sliderApp example (http://bokeh.pydata.org/en/latest/docs/server_gallery/sliders_server.html) with one plot of ‘timestamp’ versus ‘value’ columns in the data frame. I want to have a single text input field (like the ‘title’ box in the slider example) where a user can input a name. I want to filter the pandas data frame where value in ‘Name’ column is equal to the user-input and plot only the timestamps and values corresponding to that name.

I took the slider app code (https://github.com/bokeh/bokeh/blob/master/examples/app/sliders_applet/sliders_app.py) as a template and tried to load the data frame from the file into a separate obj.df field in the “create” function. But apparently that doesn’t work - I get this error:

AttributeError: unexpected attribute ‘df’ to SlidersApp, possible attributes are children, disabled, height, inputs, name, plot, session, source, tags, text or width

How do I load data from a local file?

Thanks!

MS

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/73f2c5c1-7ba3-4fa8-b628-23f537208114%40continuum.io.

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