Bar chart not happy with my data, can't figure out why

Hi,

I have a DataFrame called campaigns that has the following
info:

            Delivery

date Google Tracking Code Visits Revenue Transactions

0 2013-09-11 msag1413e 2777 3776.00 43

1 2013-09-11 mss1113e 3361 9606.50 40

2 2013-09-18 mss1813e 3140 19269.28 68

3 2013-10-02 mso213e 3111 47121.60 157

4 2013-10-08 mso813e2 2306 13271.43 47

5 2013-10-15 mso1413e 2097 28417.80 89

6 2013-10-17 mssigns13 3135 1285.47 12

7 2013-10-22 sepp102213 1925 694.36 8

8 2013-11-08 msn813e1 1839 4572.00 16

9 NaT MSS113B1 1774 1101.00 12

When I tried to create a bar chart:

bar = Bar(campaigns)

bar.title(“Email Campaign Results”) \

    .legend(True)

\

.xlabel(“Google Tracking Code”).ylabel(“Visits”) \

.width(600).height(400) \

.notebook().show()

I got the following error:

TypeError: cannot operate on a series with out a rhs of a
series/ndarray of type datetime64[ns] or a timedelta

What I am doing wrong? It’s not because of the Google
Tracking Code column; I tried using Transaction and got the same error message. I tried switching xlabel and ylabel and got the same result. With matplotlib, it’s plotting just fine:

campaigns.plot(x=‘Google Tracking Code’, y=‘Visits’, kind=‘barh’, title=‘Number of Visits’, figsize=(9,6))

Any thoughts would be greatly appreciated.

Thanks!

Anders

Did you try with:

bar = Bar(campaigns.Visits)

or something like that… I mean passing the column you want to plot

Btw, do you have a minimal example to reproduce, I mean… an IPython notebook or something like that to explore the dataframe and how is structured.

Thanks.

···

On Thu, Jul 17, 2014 at 5:03 PM, [email protected] wrote:

Hi,

I have a DataFrame called campaigns that has the following
info:

            Delivery

date Google Tracking Code Visits Revenue Transactions

0 2013-09-11 msag1413e 2777 3776.00 43

1 2013-09-11 mss1113e 3361 9606.50 40

2 2013-09-18 mss1813e 3140 19269.28 68

3 2013-10-02 mso213e 3111 47121.60 157

4 2013-10-08 mso813e2 2306 13271.43 47

5 2013-10-15 mso1413e 2097 28417.80 89

6 2013-10-17 mssigns13 3135 1285.47 12

7 2013-10-22 sepp102213 1925 694.36 8

8 2013-11-08 msn813e1 1839 4572.00 16

9 NaT MSS113B1 1774 1101.00 12

When I tried to create a bar chart:

bar = Bar(campaigns)

bar.title(“Email Campaign Results”) \

    .legend(True)

\

.xlabel(“Google Tracking Code”).ylabel(“Visits”) \

.width(600).height(400) \

.notebook().show()

I got the following error:

TypeError: cannot operate on a series with out a rhs of a
series/ndarray of type datetime64[ns] or a timedelta

What I am doing wrong? It’s not because of the Google
Tracking Code column; I tried using Transaction and got the same error message. I tried switching xlabel and ylabel and got the same result. With matplotlib, it’s plotting just fine:

campaigns.plot(x=‘Google Tracking Code’, y=‘Visits’, kind=‘barh’, title=‘Number of Visits’, figsize=(9,6))

Any thoughts would be greatly appreciated.

Thanks!

Anders

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/cfc9a9ad-8777-4880-b765-8d17907211aa%40continuum.io.

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

Sorry, forgot to put it in. Here’s the code to reproduce it, which you can paste into an IPython Notebook:

import pandas as pd
from bokeh.charts import Bar
import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,
‘10/22/2013’, ‘11/8/2013’],
‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
'sepp102213 ', 'msn813e1 '],
‘Visits’: [‘2777’, ‘3361’, ‘3140’, ‘3111’, ‘2306’, ‘2097’, ‘3135’, ‘1925’, ‘1839’],
‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],
‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]
})

bar = Bar(campaign)

bar.title(“Email Campaign Results”)
.legend(True)
.ylabel(“Transaction”).xlabel(“Visits”)
.width(600).height(400)
.notebook().show()

if I add Visits as you suggested:

bar = Bar(campaigns.Visits)

I get the error:

NameError: name 'Visits' is not defined


But after seeing your comment, what I realized is that from wherever I copied the example, I got it wrong -- I define the x and y labels, but not x and y.
I went back to the Bokeh documentation, and I'm having trouble figuring out where the documentation for bar charts is; the doc for a number of
the parameters, which aren't unique to bar charts, is in the User's Guide, but not the doc for the basic command itself. If I type

Bar?

It tells me there isn't a doc string. Any suggestions?

Thanks!
Anders



···

On Thursday, July 17, 2014 5:02:09 PM UTC-4, Damian Avila wrote:

Did you try with:

bar = Bar(campaigns.Visits)

or something like that… I mean passing the column you want to plot

Btw, do you have a minimal example to reproduce, I mean… an IPython notebook or something like that to explore the dataframe and how is structured.

Hi!

I got your plot working ‘Google Tracking Code’ vs ‘Visits’ (attached) with the following code:

import pandas as pd

from bokeh.charts import Bar

import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,

‘10/22/2013’, ‘11/8/2013’],

‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

'sepp102213 ', 'msn813e1 '],

‘Visits’: [2777, 3361, 3140, 3111, 2306, 2097, 3135, 1925, 1839],

‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],

‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]

}, index=['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

'sepp102213 ', 'msn813e1 '])

bar_columns=campaign[[“Visits”]]

bar = Bar(bar_columns)

bar.title(“Email Campaign Results”).legend(True).ylabel(“Visits”).xlabel(“Google Tracking Code”).width(600).height(400).notebook().show()

Solution:

To select a column you should do campaign[[“Visits”]] instead of campaign.Visits.

The ‘x’ categories of your plot should be the index (row_labels) of your DataFrame.

You had your Visits values as strings, they should be integers.

Here is a notebook with some Charts examples: http://nbviewer.ipython.org/github/ContinuumIO/bokeh/blob/master/examples/charts/charts.ipynb

Hope this helps!

Christine

···

On Thursday, July 17, 2014 5:28:44 PM UTC-5, [email protected] wrote:

Sorry, forgot to put it in. Here’s the code to reproduce it, which you can paste into an IPython Notebook:

import pandas as pd
from bokeh.charts import Bar
import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,
‘10/22/2013’, ‘11/8/2013’],
‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
'sepp102213 ', 'msn813e1 '],
‘Visits’: [‘2777’, ‘3361’, ‘3140’, ‘3111’, ‘2306’, ‘2097’, ‘3135’, ‘1925’, ‘1839’],
‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],
‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]
})

bar = Bar(campaign)

bar.title(“Email Campaign Results”)
.legend(True)
.ylabel(“Transaction”).xlabel(“Visits”)
.width(600).height(400)
.notebook().show()

if I add Visits as you suggested:

bar = Bar(campaigns.Visits)

I get the error:

NameError: name 'Visits' is not defined




But after seeing your comment, what I realized is that from wherever I copied the example, I got it wrong -- I define the x and y labels, but not x and y.
I went back to the Bokeh documentation, and I'm having trouble figuring out where the documentation for bar charts is; the doc for a number of
the parameters, which aren't unique to bar charts, is in the User's Guide, but not the doc for the basic command itself. If I type


Bar?


It tells me there isn't a doc string. Any suggestions?


Thanks!
Anders






On Thursday, July 17, 2014 5:02:09 PM UTC-4, Damian Avila wrote:

Did you try with:

bar = Bar(campaigns.Visits)

or something like that… I mean passing the column you want to plot

Btw, do you have a minimal example to reproduce, I mean… an IPython notebook or something like that to explore the dataframe and how is structured.

Thanks Christine to help with this issue.
An issue was opened about the needs to support more “common” dataframe structures.

We will eventually be able to provide Bokeh.charts with a “data-ingest” machinery rich enough to support several kind of reasonable inputs.

Cheers.

Damián.

···

On Thu, Jul 24, 2014 at 7:00 PM, [email protected] wrote:

Hi!

I got your plot working ‘Google Tracking Code’ vs ‘Visits’ (attached) with the following code:

import pandas as pd

from bokeh.charts import Bar

import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,

‘10/22/2013’, ‘11/8/2013’],

‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

'sepp102213 ', 'msn813e1 '],

‘Visits’: [2777, 3361, 3140, 3111, 2306, 2097, 3135, 1925, 1839],

‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],

‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]

}, index=['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

'sepp102213 ', 'msn813e1 '])

bar_columns=campaign[[“Visits”]]

bar = Bar(bar_columns)

bar.title(“Email Campaign Results”).legend(True).ylabel(“Visits”).xlabel(“Google Tracking Code”).width(600).height(400).notebook().show()

Solution:

To select a column you should do campaign[[“Visits”]] instead of campaign.Visits.

The ‘x’ categories of your plot should be the index (row_labels) of your DataFrame.

You had your Visits values as strings, they should be integers.

Here is a notebook with some Charts examples: http://nbviewer.ipython.org/github/ContinuumIO/bokeh/blob/master/examples/charts/charts.ipynb

Hope this helps!

Christine

On Thursday, July 17, 2014 5:28:44 PM UTC-5, [email protected] wrote:

Sorry, forgot to put it in. Here’s the code to reproduce it, which you can paste into an IPython Notebook:

import pandas as pd

from bokeh.charts import Bar
import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,

                      '10/22/2013', '11/8/2013'],

‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

                      'sepp102213 ', 'msn813e1 '],

‘Visits’: [‘2777’, ‘3361’, ‘3140’, ‘3111’, ‘2306’, ‘2097’, ‘3135’, ‘1925’, ‘1839’],

‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],
‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]

})

bar = Bar(campaign)

bar.title(“Email Campaign Results”)
.legend(True) \

    .ylabel("Transaction").xlabel("Visits") \
    .width(600).height(400) \
    .notebook().show()

if I add Visits as you suggested:

bar = Bar(campaigns.Visits)

I get the error:

NameError: name 'Visits' is not defined




But after seeing your comment, what I realized is that from wherever I copied the example, I got it wrong -- I define the x and y labels, but not x and y.
I went back to the Bokeh documentation, and I'm having trouble figuring out where the documentation for bar charts is; the doc for a number of
the parameters, which aren't unique to bar charts, is in the User's Guide, but not the doc for the basic command itself. If I type


Bar?


It tells me there isn't a doc string. Any suggestions?


Thanks!
Anders






On Thursday, July 17, 2014 5:02:09 PM UTC-4, Damian Avila wrote:

Did you try with:

bar = Bar(campaigns.Visits)

or something like that… I mean passing the column you want to plot

Btw, do you have a minimal example to reproduce, I mean… an IPython notebook or something like that to explore the dataframe and how is structured.

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/80dc77f7-2a77-434c-84b8-93095be2078f%40continuum.io.

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

Thank you so much, Christine! Works like a charm.

And thanks very much Damian for opening that issue. You might want to use matplotlib’s approach as inspiration. Matplotlib allows you to use the index for the x axis and allows you to plot all of a DataFrame’s columns. But it also allows you to specify the X and Y axis directly, which produces code that’s simple and easy to understand:

campaigns.plot(x=‘Google Tracking Code’, y=‘Visits’, kind=‘bar’, title=‘Number of Visitors’, color=‘purple’)

In Bokeh, this approach might look something like the following:
bar = Bar(campaigns, x=‘Google Tracking Code’, y=‘Visits’).title(“Email Campaign Results”). fill_color(‘tomato’).width(600).height(400).notebook().show()

X and Y would be optional parameters. If X is None – ie it wasn’t specified – you use the index. If y is None, you use the entire DataFrame.

Cheers,

Anders

···

On Thursday, July 24, 2014 8:40:44 PM UTC-4, Damian Avila wrote:

Thanks Christine to help with this issue.
An issue was opened about the needs to support more “common” dataframe structures.

We will eventually be able to provide Bokeh.charts with a “data-ingest” machinery rich enough to support several kind of reasonable inputs.

Cheers.

Damián.

On Thu, Jul 24, 2014 at 7:00 PM, [email protected] wrote:

Hi!

I got your plot working ‘Google Tracking Code’ vs ‘Visits’ (attached) with the following code:

import pandas as pd

from bokeh.charts import Bar

import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,

‘10/22/2013’, ‘11/8/2013’],

‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

'sepp102213 ', 'msn813e1 '],

‘Visits’: [2777, 3361, 3140, 3111, 2306, 2097, 3135, 1925, 1839],

‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],

‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]

}, index=['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

'sepp102213 ', 'msn813e1 '])

bar_columns=campaign[[“Visits”]]

bar = Bar(bar_columns)

bar.title(“Email Campaign Results”).legend(True).ylabel(“Visits”).xlabel(“Google Tracking Code”).width(600).height(400).notebook().show()

Solution:

To select a column you should do campaign[[“Visits”]] instead of campaign.Visits.

The ‘x’ categories of your plot should be the index (row_labels) of your DataFrame.

You had your Visits values as strings, they should be integers.

Here is a notebook with some Charts examples: http://nbviewer.ipython.org/github/ContinuumIO/bokeh/blob/master/examples/charts/charts.ipynb

Hope this helps!

Christine

On Thursday, July 17, 2014 5:28:44 PM UTC-5, [email protected] wrote:

Sorry, forgot to put it in. Here’s the code to reproduce it, which you can paste into an IPython Notebook:

import pandas as pd

from bokeh.charts import Bar
import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,

                      '10/22/2013', '11/8/2013'],

‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

                      'sepp102213 ', 'msn813e1 '],

‘Visits’: [‘2777’, ‘3361’, ‘3140’, ‘3111’, ‘2306’, ‘2097’, ‘3135’, ‘1925’, ‘1839’],

‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],
‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]

})

bar = Bar(campaign)

bar.title(“Email Campaign Results”)
.legend(True) \

    .ylabel("Transaction").xlabel("Visits") \
    .width(600).height(400) \
    .notebook().show()

if I add Visits as you suggested:

bar = Bar(campaigns.Visits)

I get the error:

NameError: name 'Visits' is not defined




But after seeing your comment, what I realized is that from wherever I copied the example, I got it wrong -- I define the x and y labels, but not x and y.
I went back to the Bokeh documentation, and I'm having trouble figuring out where the documentation for bar charts is; the doc for a number of
the parameters, which aren't unique to bar charts, is in the User's Guide, but not the doc for the basic command itself. If I type


Bar?


It tells me there isn't a doc string. Any suggestions?


Thanks!
Anders






On Thursday, July 17, 2014 5:02:09 PM UTC-4, Damian Avila wrote:

Did you try with:

bar = Bar(campaigns.Visits)

or something like that… I mean passing the column you want to plot

Btw, do you have a minimal example to reproduce, I mean… an IPython notebook or something like that to explore the dataframe and how is structured.

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/80dc77f7-2a77-434c-84b8-93095be2078f%40continuum.io.

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

Thanks for the feedback Anders! I opened an issue for scatterplots: Thoughts on DataFrame input data for chart.Scatter · Issue #886 · bokeh/bokeh · GitHub, but it’s actually the same issue you are mentioning, so I can add your suggestions there to remind us when we do the changes. Glad I could help! :slight_smile:

···

On Friday, July 25, 2014 7:02:58 AM UTC-5, [email protected] wrote:

Thank you so much, Christine! Works like a charm.

And thanks very much Damian for opening that issue. You might want to use matplotlib’s approach as inspiration. Matplotlib allows you to use the index for the x axis and allows you to plot all of a DataFrame’s columns. But it also allows you to specify the X and Y axis directly, which produces code that’s simple and easy to understand:

campaigns.plot(x=‘Google Tracking Code’, y=‘Visits’, kind=‘bar’, title=‘Number of Visitors’, color=‘purple’)

In Bokeh, this approach might look something like the following:
bar = Bar(campaigns, x=‘Google Tracking Code’, y=‘Visits’).title(“Email Campaign Results”). fill_color(‘tomato’).width(600).height(400).notebook().show()

X and Y would be optional parameters. If X is None – ie it wasn’t specified – you use the index. If y is None, you use the entire DataFrame.

Cheers,

Anders

On Thursday, July 24, 2014 8:40:44 PM UTC-4, Damian Avila wrote:

Thanks Christine to help with this issue.
An issue was opened about the needs to support more “common” dataframe structures.

We will eventually be able to provide Bokeh.charts with a “data-ingest” machinery rich enough to support several kind of reasonable inputs.

Cheers.

Damián.

On Thu, Jul 24, 2014 at 7:00 PM, [email protected] wrote:

Hi!

I got your plot working ‘Google Tracking Code’ vs ‘Visits’ (attached) with the following code:

import pandas as pd

from bokeh.charts import Bar

import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,

‘10/22/2013’, ‘11/8/2013’],

‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

'sepp102213 ', 'msn813e1 '],

‘Visits’: [2777, 3361, 3140, 3111, 2306, 2097, 3135, 1925, 1839],

‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],

‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]

}, index=['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

'sepp102213 ', 'msn813e1 '])

bar_columns=campaign[[“Visits”]]

bar = Bar(bar_columns)

bar.title(“Email Campaign Results”).legend(True).ylabel(“Visits”).xlabel(“Google Tracking Code”).width(600).height(400).notebook().show()

Solution:

To select a column you should do campaign[[“Visits”]] instead of campaign.Visits.

The ‘x’ categories of your plot should be the index (row_labels) of your DataFrame.

You had your Visits values as strings, they should be integers.

Here is a notebook with some Charts examples: http://nbviewer.ipython.org/github/ContinuumIO/bokeh/blob/master/examples/charts/charts.ipynb

Hope this helps!

Christine

On Thursday, July 17, 2014 5:28:44 PM UTC-5, [email protected] wrote:

Sorry, forgot to put it in. Here’s the code to reproduce it, which you can paste into an IPython Notebook:

import pandas as pd

from bokeh.charts import Bar
import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,

                      '10/22/2013', '11/8/2013'],

‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

                      'sepp102213 ', 'msn813e1 '],

‘Visits’: [‘2777’, ‘3361’, ‘3140’, ‘3111’, ‘2306’, ‘2097’, ‘3135’, ‘1925’, ‘1839’],

‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],
‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]

})

bar = Bar(campaign)

bar.title(“Email Campaign Results”)
.legend(True) \

    .ylabel("Transaction").xlabel("Visits") \
    .width(600).height(400) \
    .notebook().show()

if I add Visits as you suggested:

bar = Bar(campaigns.Visits)

I get the error:

NameError: name 'Visits' is not defined




But after seeing your comment, what I realized is that from wherever I copied the example, I got it wrong -- I define the x and y labels, but not x and y.
I went back to the Bokeh documentation, and I'm having trouble figuring out where the documentation for bar charts is; the doc for a number of
the parameters, which aren't unique to bar charts, is in the User's Guide, but not the doc for the basic command itself. If I type


Bar?


It tells me there isn't a doc string. Any suggestions?


Thanks!
Anders






On Thursday, July 17, 2014 5:02:09 PM UTC-4, Damian Avila wrote:

Did you try with:

bar = Bar(campaigns.Visits)

or something like that… I mean passing the column you want to plot

Btw, do you have a minimal example to reproduce, I mean… an IPython notebook or something like that to explore the dataframe and how is structured.

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/80dc77f7-2a77-434c-84b8-93095be2078f%40continuum.io.

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

Thanks so much, Christine!

My colleagues and I have been kicking around an idea we'd like to propose as one more possible enhancement. When folks are making bar graphs, scatter charts, etc., a lot of the time they want to chart a simple aggregation of the data. Currently, first you have to aggregate the data, then you create a chart. What would be really useful is if you could do it in one shot ala Excel Pivot Charts. For example:

Scatter(products, x='Year', y='Product Type', function='count')
or
Scatter(products, x='Year', y='Product Type', function='sum', aggregate_field='Revenue')

Does it make sense for me to add this suggestion to the issue you opened? Or is this different enough that I should post it as new feature request? I've never been involved in a GitHub project before, so I'm not sure what the best way to do this is.

FYI, the reason I've been putting in these suggestions is that in about a month we're going to launch an initiative to help more nonprofits and more folks in the community using pandas/IPython Notebook, with a particular focus on increasing the diversity of the data science world, and as part of that effort we'd like to promote using Bokeh instead of matplotlib. For example, in the spring I'm going to teach a class called "pandas for Excel Users" and I'd like to put Bokeh at the center of it.

Thanks!
Anders

Thanks so much, Christine!

My colleagues and I have been kicking around an idea we'd like to propose
as one more possible enhancement. When folks are making bar graphs,
scatter charts, etc., a lot of the time they want to chart a simple
aggregation of the data. Currently, first you have to aggregate the data,
then you create a chart. What would be really useful is if you could do it
in one shot ala Excel Pivot Charts. For example:

Scatter(products, x='Year', y='Product Type', function='count')
or
Scatter(products, x='Year', y='Product Type', function='sum',
aggregate_field='Revenue')

Does it make sense for me to add this suggestion to the issue you opened?
Or is this different enough that I should post it as new feature request?
I've never been involved in a GitHub project before, so I'm not sure what
the best way to do this is.

I think this is a nice suggestion and a nice enhancement to the
bokeh.charts interface. It should probably be a separate Github issue,
though.

FYI, the reason I've been putting in these suggestions is that in about a
month we're going to launch an initiative to help more nonprofits and more
folks in the community using pandas/IPython Notebook, with a particular
focus on increasing the diversity of the data science world, and as part of
that effort we'd like to promote using Bokeh instead of matplotlib. For
example, in the spring I'm going to teach a class called "pandas for Excel
Users" and I'd like to put Bokeh at the center of it.

This is great! It should be worth noting that the mpl compatibility of
Bokeh is something we intend to continue supporting as a first-class
feature, so if there are plots that people would like to do via Seaborn or
ggplot.py, those should all work fine with bokeh. (e.g.
http://bokeh.pydata.org/docs/gallery/violin.html\)

You know what else would be great, is to demonstrate using xlwings to load
existing Excel files, then plot them in an IPython notebook. You can
resize the Excel window to the left half of the screen, and have a Notebook
window on the right half. :slight_smile:

-Peter

···

On Wed, Jul 30, 2014 at 7:26 AM, <[email protected]> wrote:

Thanks, Peter! I'll put it in as a separate issue. And thanks for the heads up about xlwings. It looks like it's got a lot of potential -- and unlike Data Nitro it's free and open source.

Anders

Has something changed so that it’s not rendering anything now, using 0.10.0 ? I tried to copy paste the code Christine provided and it renders nothing :

Same DataFrame format than in this question I asked today : basic bokeh Bar chart - Stack Overflow with the labels as the dataframe index.
any hints ?

thanks

···

On Friday, July 25, 2014 at 12:00:16 AM UTC+2, Christine Doig wrote:

Hi!

I got your plot working ‘Google Tracking Code’ vs ‘Visits’ (attached) with the following code:

import pandas as pd

from bokeh.charts import Bar

import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,

‘10/22/2013’, ‘11/8/2013’],

‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

'sepp102213 ', 'msn813e1 '],

‘Visits’: [2777, 3361, 3140, 3111, 2306, 2097, 3135, 1925, 1839],

‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],

‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]

}, index=['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',

'sepp102213 ', 'msn813e1 '])

bar_columns=campaign[[“Visits”]]

bar = Bar(bar_columns)

bar.title(“Email Campaign Results”).legend(True).ylabel(“Visits”).xlabel(“Google Tracking Code”).width(600).height(400).notebook().show()

Solution:

To select a column you should do campaign[[“Visits”]] instead of campaign.Visits.

The ‘x’ categories of your plot should be the index (row_labels) of your DataFrame.

You had your Visits values as strings, they should be integers.

Here is a notebook with some Charts examples: http://nbviewer.ipython.org/github/ContinuumIO/bokeh/blob/master/examples/charts/charts.ipynb

Hope this helps!

Christine

On Thursday, July 17, 2014 5:28:44 PM UTC-5, [email protected] wrote:

Sorry, forgot to put it in. Here’s the code to reproduce it, which you can paste into an IPython Notebook:

import pandas as pd
from bokeh.charts import Bar
import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,
‘10/22/2013’, ‘11/8/2013’],
‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
'sepp102213 ', 'msn813e1 '],
‘Visits’: [‘2777’, ‘3361’, ‘3140’, ‘3111’, ‘2306’, ‘2097’, ‘3135’, ‘1925’, ‘1839’],
‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],
‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]
})

bar = Bar(campaign)

bar.title(“Email Campaign Results”)
.legend(True)
.ylabel(“Transaction”).xlabel(“Visits”)
.width(600).height(400)
.notebook().show()

if I add Visits as you suggested:

bar = Bar(campaigns.Visits)

I get the error:

NameError: name 'Visits' is not defined




But after seeing your comment, what I realized is that from wherever I copied the example, I got it wrong -- I define the x and y labels, but not x and y.
I went back to the Bokeh documentation, and I'm having trouble figuring out where the documentation for bar charts is; the doc for a number of
the parameters, which aren't unique to bar charts, is in the User's Guide, but not the doc for the basic command itself. If I type


Bar?


It tells me there isn't a doc string. Any suggestions?


Thanks!
Anders






On Thursday, July 17, 2014 5:02:09 PM UTC-4, Damian Avila wrote:

Did you try with:

bar = Bar(campaigns.Visits)

or something like that… I mean passing the column you want to plot

Btw, do you have a minimal example to reproduce, I mean… an IPython notebook or something like that to explore the dataframe and how is structured.

The bokeh.charts was changed somewhat dramatically in 0.10 to provide a much better, more consistent, dataframe-centric interface. Please see:

  http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html

For this example, you have to tell it what column to render (even if there is only one column, perhaps that can be improved). The following:

  bar = Bar(bar_columns, 'Visits')

Produced the expected chart for me. This pattern of "dataframe + column name to use" is common throughout the new interface (and has been requested for some time).

Also note, you can import show from bokeh.io as well, instead of bokeh.plotting

Thanks,

Bryan

···

On Oct 9, 2015, at 9:48 AM, [email protected] wrote:

Has something changed so that it's not rendering anything now, using 0.10.0 ? I tried to copy paste the code Christine provided and it renders nothing :

basic bokeh Bar chart · GitHub

Same DataFrame format than in this question I asked today : basic bokeh Bar chart - Stack Overflow with the labels as the dataframe index.
any hints ?

thanks

On Friday, July 25, 2014 at 12:00:16 AM UTC+2, Christine Doig wrote:
Hi!

I got your plot working 'Google Tracking Code' vs 'Visits' (attached) with the following code:

import pandas as pd
from bokeh.charts import Bar
import bokeh
bokeh.load_notebook()

campaign = pd.DataFrame({'Delivery date': ['9/11/2013', '9/11/2013', '9/18/2013', '10/2/2013', '10/8/2013', '10/15/2013', '10/17/2013',
                          '10/22/2013', '11/8/2013'],
'Google Tracking Code': ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
                          'sepp102213 ', 'msn813e1 '],
'Visits': [2777, 3361, 3140, 3111, 2306, 2097, 3135, 1925, 1839],
'Revenue': ['3776', '9606.5', '19269.28', '47121.6', '13271.43', '28417.8', '1285.47', '694.36', '4572'],
'Transactions': ['43', '40', '68', '157', '47', '89', '12', '8', '16']
}, index=['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
                          'sepp102213 ', 'msn813e1 '])

bar_columns=campaign[["Visits"]]
bar = Bar(bar_columns)
bar.title("Email Campaign Results").legend(True).ylabel("Visits").xlabel("Google Tracking Code").width(600).height(400).notebook().show()

Solution:
To select a column you should do campaign[["Visits"]] instead of campaign.Visits.
The 'x' categories of your plot should be the index (row_labels) of your DataFrame.
You had your Visits values as strings, they should be integers.

Here is a notebook with some Charts examples: http://nbviewer.ipython.org/github/ContinuumIO/bokeh/blob/master/examples/charts/charts.ipynb

Hope this helps!
Christine

On Thursday, July 17, 2014 5:28:44 PM UTC-5, aschne...@gmail.com wrote:
Sorry, forgot to put it in. Here's the code to reproduce it, which you can paste into an IPython Notebook:

import pandas as pd
from bokeh.charts import Bar
import bokeh
bokeh.load_notebook()

campaign = pd.DataFrame({'Delivery date': ['9/11/2013', '9/11/2013', '9/18/2013', '10/2/2013', '10/8/2013', '10/15/2013', '10/17/2013',
                          '10/22/2013', '11/8/2013'],
'Google Tracking Code': ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
                          'sepp102213 ', 'msn813e1 '],
'Visits': ['2777', '3361', '3140', '3111', '2306', '2097', '3135', '1925', '1839'],
'Revenue': ['3776', '9606.5', '19269.28', '47121.6', '13271.43', '28417.8', '1285.47', '694.36', '4572'],
'Transactions': ['43', '40', '68', '157', '47', '89', '12', '8', '16']
})

bar = Bar(campaign)
bar.title("Email Campaign Results") \
        .legend(True) \
        .ylabel("Transaction").xlabel("Visits") \
        .width(600).height(400) \
        .notebook().show()

if I add Visits as you suggested:

bar = Bar(campaigns.Visits)

I get the error:

NameError: name 'Visits' is not defined

But after seeing your comment, what I realized is that from wherever I copied the example, I got it wrong -- I define the x and y labels, but not x and y.
I went back to the Bokeh documentation, and I'm having trouble figuring out where the documentation for bar charts is; the doc for a number of
the parameters, which aren't unique to bar charts, is in the User's Guide, but not the doc for the basic command itself. If I type

Bar?

It tells me there isn't a doc string. Any suggestions?

Thanks!
Anders

On Thursday, July 17, 2014 5:02:09 PM UTC-4, Damian Avila wrote:
Did you try with:

bar = Bar(campaigns.Visits)

or something like that... I mean passing the column you want to plot

Btw, do you have a minimal example to reproduce, I mean... an IPython notebook or something like that to explore the dataframe and how is structured.

--
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/7f878058-2726-4731-bfea-82b5b2ea65f6%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

thanks for poiting me in the right direction. The un intuitive part
for me is that labels on the x-axis are not the index of the
DataFrame, which is basically what I wanted.
I found a solution doing this however :

import pandas as pd
from bokeh.charts import Bar
from bokeh.io import output_notebook, show
output_notebook()
dict = {'values': {u'A': 10, u'B': 20}}
df = pd.DataFrame(dict)
df['label'] = df.index
df
p = Bar(df, values='values',label='label')
show(p)

isn't it possible to pass the index directly in the label= kwarg ?

···

On Fri, Oct 9, 2015 at 10:26 PM, Bryan Van de Ven <[email protected]> wrote:

The bokeh.charts was changed somewhat dramatically in 0.10 to provide a much better, more consistent, dataframe-centric interface. Please see:

        http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html

For this example, you have to tell it what column to render (even if there is only one column, perhaps that can be improved). The following:

        bar = Bar(bar_columns, 'Visits')

Produced the expected chart for me. This pattern of "dataframe + column name to use" is common throughout the new interface (and has been requested for some time).

Also note, you can import show from bokeh.io as well, instead of bokeh.plotting

Thanks,

Bryan

On Oct 9, 2015, at 9:48 AM, [email protected] wrote:

Has something changed so that it's not rendering anything now, using 0.10.0 ? I tried to copy paste the code Christine provided and it renders nothing :

basic bokeh Bar chart · GitHub

Same DataFrame format than in this question I asked today : basic bokeh Bar chart - Stack Overflow with the labels as the dataframe index.
any hints ?

thanks

On Friday, July 25, 2014 at 12:00:16 AM UTC+2, Christine Doig wrote:
Hi!

I got your plot working 'Google Tracking Code' vs 'Visits' (attached) with the following code:

import pandas as pd
from bokeh.charts import Bar
import bokeh
bokeh.load_notebook()

campaign = pd.DataFrame({'Delivery date': ['9/11/2013', '9/11/2013', '9/18/2013', '10/2/2013', '10/8/2013', '10/15/2013', '10/17/2013',
                          '10/22/2013', '11/8/2013'],
'Google Tracking Code': ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
                          'sepp102213 ', 'msn813e1 '],
'Visits': [2777, 3361, 3140, 3111, 2306, 2097, 3135, 1925, 1839],
'Revenue': ['3776', '9606.5', '19269.28', '47121.6', '13271.43', '28417.8', '1285.47', '694.36', '4572'],
'Transactions': ['43', '40', '68', '157', '47', '89', '12', '8', '16']
}, index=['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
                          'sepp102213 ', 'msn813e1 '])

bar_columns=campaign[["Visits"]]
bar = Bar(bar_columns)
bar.title("Email Campaign Results").legend(True).ylabel("Visits").xlabel("Google Tracking Code").width(600).height(400).notebook().show()

Solution:
To select a column you should do campaign[["Visits"]] instead of campaign.Visits.
The 'x' categories of your plot should be the index (row_labels) of your DataFrame.
You had your Visits values as strings, they should be integers.

Here is a notebook with some Charts examples: http://nbviewer.ipython.org/github/ContinuumIO/bokeh/blob/master/examples/charts/charts.ipynb

Hope this helps!
Christine

On Thursday, July 17, 2014 5:28:44 PM UTC-5, aschne...@gmail.com wrote:
Sorry, forgot to put it in. Here's the code to reproduce it, which you can paste into an IPython Notebook:

import pandas as pd
from bokeh.charts import Bar
import bokeh
bokeh.load_notebook()

campaign = pd.DataFrame({'Delivery date': ['9/11/2013', '9/11/2013', '9/18/2013', '10/2/2013', '10/8/2013', '10/15/2013', '10/17/2013',
                          '10/22/2013', '11/8/2013'],
'Google Tracking Code': ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
                          'sepp102213 ', 'msn813e1 '],
'Visits': ['2777', '3361', '3140', '3111', '2306', '2097', '3135', '1925', '1839'],
'Revenue': ['3776', '9606.5', '19269.28', '47121.6', '13271.43', '28417.8', '1285.47', '694.36', '4572'],
'Transactions': ['43', '40', '68', '157', '47', '89', '12', '8', '16']
})

bar = Bar(campaign)
bar.title("Email Campaign Results") \
        .legend(True) \
        .ylabel("Transaction").xlabel("Visits") \
        .width(600).height(400) \
        .notebook().show()

if I add Visits as you suggested:

bar = Bar(campaigns.Visits)

I get the error:

NameError: name 'Visits' is not defined

But after seeing your comment, what I realized is that from wherever I copied the example, I got it wrong -- I define the x and y labels, but not x and y.
I went back to the Bokeh documentation, and I'm having trouble figuring out where the documentation for bar charts is; the doc for a number of
the parameters, which aren't unique to bar charts, is in the User's Guide, but not the doc for the basic command itself. If I type

Bar?

It tells me there isn't a doc string. Any suggestions?

Thanks!
Anders

On Thursday, July 17, 2014 5:02:09 PM UTC-4, Damian Avila wrote:
Did you try with:

bar = Bar(campaigns.Visits)

or something like that... I mean passing the column you want to plot

Btw, do you have a minimal example to reproduce, I mean... an IPython notebook or something like that to explore the dataframe and how is structured.

--
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/7f878058-2726-4731-bfea-82b5b2ea65f6%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to a topic in the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/1mLboNB18io/unsubscribe\.
To unsubscribe from this group and all its topics, 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/1CB93DA8-FC39-417B-87D8-0FCE7B259661%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi Benoit,

I'm glad there is a simple workaround. The interface is still new, so a "spelling" for using the index might just be a current oversight. Can you open a feature request on the GitHub issue tracker? That will help make sure the relevant developers see it.

Thanks,

Bryan

···

On Oct 9, 2015, at 9:38 PM, Benoit Barthelet <[email protected]> wrote:

thanks for poiting me in the right direction. The un intuitive part
for me is that labels on the x-axis are not the index of the
DataFrame, which is basically what I wanted.
I found a solution doing this however :

import pandas as pd
from bokeh.charts import Bar
from bokeh.io import output_notebook, show
output_notebook()
dict = {'values': {u'A': 10, u'B': 20}}
df = pd.DataFrame(dict)
df['label'] = df.index
df
p = Bar(df, values='values',label='label')
show(p)

isn't it possible to pass the index directly in the label= kwarg ?

On Fri, Oct 9, 2015 at 10:26 PM, Bryan Van de Ven <[email protected]> wrote:

The bokeh.charts was changed somewhat dramatically in 0.10 to provide a much better, more consistent, dataframe-centric interface. Please see:

       http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html

For this example, you have to tell it what column to render (even if there is only one column, perhaps that can be improved). The following:

       bar = Bar(bar_columns, 'Visits')

Produced the expected chart for me. This pattern of "dataframe + column name to use" is common throughout the new interface (and has been requested for some time).

Also note, you can import show from bokeh.io as well, instead of bokeh.plotting

Thanks,

Bryan

On Oct 9, 2015, at 9:48 AM, [email protected] wrote:

Has something changed so that it's not rendering anything now, using 0.10.0 ? I tried to copy paste the code Christine provided and it renders nothing :

basic bokeh Bar chart · GitHub

Same DataFrame format than in this question I asked today : basic bokeh Bar chart - Stack Overflow with the labels as the dataframe index.
any hints ?

thanks

On Friday, July 25, 2014 at 12:00:16 AM UTC+2, Christine Doig wrote:
Hi!

I got your plot working 'Google Tracking Code' vs 'Visits' (attached) with the following code:

import pandas as pd
from bokeh.charts import Bar
import bokeh
bokeh.load_notebook()

campaign = pd.DataFrame({'Delivery date': ['9/11/2013', '9/11/2013', '9/18/2013', '10/2/2013', '10/8/2013', '10/15/2013', '10/17/2013',
                         '10/22/2013', '11/8/2013'],
'Google Tracking Code': ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
                         'sepp102213 ', 'msn813e1 '],
'Visits': [2777, 3361, 3140, 3111, 2306, 2097, 3135, 1925, 1839],
'Revenue': ['3776', '9606.5', '19269.28', '47121.6', '13271.43', '28417.8', '1285.47', '694.36', '4572'],
'Transactions': ['43', '40', '68', '157', '47', '89', '12', '8', '16']
}, index=['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
                         'sepp102213 ', 'msn813e1 '])

bar_columns=campaign[["Visits"]]
bar = Bar(bar_columns)
bar.title("Email Campaign Results").legend(True).ylabel("Visits").xlabel("Google Tracking Code").width(600).height(400).notebook().show()

Solution:
To select a column you should do campaign[["Visits"]] instead of campaign.Visits.
The 'x' categories of your plot should be the index (row_labels) of your DataFrame.
You had your Visits values as strings, they should be integers.

Here is a notebook with some Charts examples: http://nbviewer.ipython.org/github/ContinuumIO/bokeh/blob/master/examples/charts/charts.ipynb

Hope this helps!
Christine

On Thursday, July 17, 2014 5:28:44 PM UTC-5, aschne...@gmail.com wrote:
Sorry, forgot to put it in. Here's the code to reproduce it, which you can paste into an IPython Notebook:

import pandas as pd
from bokeh.charts import Bar
import bokeh
bokeh.load_notebook()

campaign = pd.DataFrame({'Delivery date': ['9/11/2013', '9/11/2013', '9/18/2013', '10/2/2013', '10/8/2013', '10/15/2013', '10/17/2013',
                         '10/22/2013', '11/8/2013'],
'Google Tracking Code': ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
                         'sepp102213 ', 'msn813e1 '],
'Visits': ['2777', '3361', '3140', '3111', '2306', '2097', '3135', '1925', '1839'],
'Revenue': ['3776', '9606.5', '19269.28', '47121.6', '13271.43', '28417.8', '1285.47', '694.36', '4572'],
'Transactions': ['43', '40', '68', '157', '47', '89', '12', '8', '16']
})

bar = Bar(campaign)
bar.title("Email Campaign Results") \
       .legend(True) \
       .ylabel("Transaction").xlabel("Visits") \
       .width(600).height(400) \
       .notebook().show()

if I add Visits as you suggested:

bar = Bar(campaigns.Visits)

I get the error:

NameError: name 'Visits' is not defined

But after seeing your comment, what I realized is that from wherever I copied the example, I got it wrong -- I define the x and y labels, but not x and y.
I went back to the Bokeh documentation, and I'm having trouble figuring out where the documentation for bar charts is; the doc for a number of
the parameters, which aren't unique to bar charts, is in the User's Guide, but not the doc for the basic command itself. If I type

Bar?

It tells me there isn't a doc string. Any suggestions?

Thanks!
Anders

On Thursday, July 17, 2014 5:02:09 PM UTC-4, Damian Avila wrote:
Did you try with:

bar = Bar(campaigns.Visits)

or something like that... I mean passing the column you want to plot

Btw, do you have a minimal example to reproduce, I mean... an IPython notebook or something like that to explore the dataframe and how is structured.

--
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/7f878058-2726-4731-bfea-82b5b2ea65f6%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to a topic in the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/1mLboNB18io/unsubscribe\.
To unsubscribe from this group and all its topics, 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/1CB93DA8-FC39-417B-87D8-0FCE7B259661%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
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/CAM0ORjnEuN9Ed3st%3DbqVJMVREkOhsjv%3DP1PFqJ57nHBpxyG-kQ%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Very nice work! Thank you SO much for implementing this new approach.

Anders

···

On Friday, October 9, 2015 at 4:26:06 PM UTC-4, Bryan Van de ven wrote:

The bokeh.charts was changed somewhat dramatically in 0.10 to provide a much better, more consistent, dataframe-centric interface. Please see:

    [http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html](http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html)

For this example, you have to tell it what column to render (even if there is only one column, perhaps that can be improved). The following:

    bar = Bar(bar_columns, 'Visits')

Produced the expected chart for me. This pattern of “dataframe + column name to use” is common throughout the new interface (and has been requested for some time).

Also note, you can import show from bokeh.io as well, instead of bokeh.plotting

Thanks,

Bryan

On Oct 9, 2015, at 9:48 AM, [email protected] wrote:

Has something changed so that it’s not rendering anything now, using 0.10.0 ? I tried to copy paste the code Christine provided and it renders nothing :

https://gist.github.com/euri10/43e95faefd57889465d5

Same DataFrame format than in this question I asked today : http://stackoverflow.com/questions/33038988/basic-bokeh-bar-chart with the labels as the dataframe index.

any hints ?

thanks

On Friday, July 25, 2014 at 12:00:16 AM UTC+2, Christine Doig wrote:

Hi!

I got your plot working ‘Google Tracking Code’ vs ‘Visits’ (attached) with the following code:

import pandas as pd

from bokeh.charts import Bar

import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,
‘10/22/2013’, ‘11/8/2013’],
‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
'sepp102213 ', 'msn813e1 '],

‘Visits’: [2777, 3361, 3140, 3111, 2306, 2097, 3135, 1925, 1839],

‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],

‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]

}, index=['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
'sepp102213 ', 'msn813e1 '])

bar_columns=campaign[[“Visits”]]

bar = Bar(bar_columns)

bar.title(“Email Campaign Results”).legend(True).ylabel(“Visits”).xlabel(“Google Tracking Code”).width(600).height(400).notebook().show()

Solution:

To select a column you should do campaign[[“Visits”]] instead of campaign.Visits.

The ‘x’ categories of your plot should be the index (row_labels) of your DataFrame.

You had your Visits values as strings, they should be integers.

Here is a notebook with some Charts examples: http://nbviewer.ipython.org/github/ContinuumIO/bokeh/blob/master/examples/charts/charts.ipynb

Hope this helps!

Christine

On Thursday, July 17, 2014 5:28:44 PM UTC-5, [email protected] wrote:

Sorry, forgot to put it in. Here’s the code to reproduce it, which you can paste into an IPython Notebook:

import pandas as pd

from bokeh.charts import Bar

import bokeh

bokeh.load_notebook()

campaign = pd.DataFrame({‘Delivery date’: [‘9/11/2013’, ‘9/11/2013’, ‘9/18/2013’, ‘10/2/2013’, ‘10/8/2013’, ‘10/15/2013’, ‘10/17/2013’,
‘10/22/2013’, ‘11/8/2013’],
‘Google Tracking Code’: ['msag1413e ', 'mss1113e ', 'mss1813e ', 'mso213e ', 'mso813e2 ', 'mso1413e ', 'mssigns13 ',
'sepp102213 ', 'msn813e1 '],

‘Visits’: [‘2777’, ‘3361’, ‘3140’, ‘3111’, ‘2306’, ‘2097’, ‘3135’, ‘1925’, ‘1839’],

‘Revenue’: [‘3776’, ‘9606.5’, ‘19269.28’, ‘47121.6’, ‘13271.43’, ‘28417.8’, ‘1285.47’, ‘694.36’, ‘4572’],

‘Transactions’: [‘43’, ‘40’, ‘68’, ‘157’, ‘47’, ‘89’, ‘12’, ‘8’, ‘16’]

})

bar = Bar(campaign)

bar.title(“Email Campaign Results”) \

    .legend(True) \
    .ylabel("Transaction").xlabel("Visits") \
    .width(600).height(400) \
    .notebook().show()

if I add Visits as you suggested:

bar = Bar(campaigns.Visits)

I get the error:

NameError: name ‘Visits’ is not defined

But after seeing your comment, what I realized is that from wherever I copied the example, I got it wrong – I define the x and y labels, but not x and y.
I went back to the Bokeh documentation, and I’m having trouble figuring out where the documentation for bar charts is; the doc for a number of

the parameters, which aren’t unique to bar charts, is in the User’s Guide, but not the doc for the basic command itself. If I type

Bar?

It tells me there isn’t a doc string. Any suggestions?

Thanks!

Anders

On Thursday, July 17, 2014 5:02:09 PM UTC-4, Damian Avila wrote:

Did you try with:

bar = Bar(campaigns.Visits)

or something like that… I mean passing the column you want to plot

Btw, do you have a minimal example to reproduce, I mean… an IPython notebook or something like that to explore the dataframe and how is structured.


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/7f878058-2726-4731-bfea-82b5b2ea65f6%40continuum.io.

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