Passing column data from pandas df to bokeh plotting function
<p>I'm working on automating plotting functions for metabolomics data with bokeh. Currently, I'm trying to read in my dataframe from CSV and iterate through the columns generating box plots for each metabolite (column).</p>

<p>I have an example df that looks like this:</p>

<pre><code>Sample  Group   AMP     ADP     ATP
1A      A       239847  239084  987374
1B      A       245098  241210  988950
2A      B       238759  200554  921032
2B      B       230029  215408  89980
</code></pre>

<p>Here is what my code looks like:</p>

<pre><code>import pandas
from bokeh.plotting import figure, output_file, show, save
from bokeh.charts import BoxPlot

df = pandas.read_csv("testdata_2.csv")

for colname, col in df.iteritems():
p = BoxPlot(df, values=df[colname], label='Group', xlabel='Group', ylabel='Peak Area',
             title=colname)
    output_file("boxplot.html")
    show(p)
</code></pre>

<p>This generates an error:</p>

<pre><code>raise ValueError("expected an element of either %s, got %r" % (nice_join(self.type_params), value))

ValueError: expected an element of either Column Name or Column String or List(Column Name or Column String
</code></pre>

<p>It seems that setting <code>values=df[colname]</code> is the issue. If I replace it with <code>values=df['colname']</code> it gives me a key error for colname. I can plot just fine if I specify a given column such as <code>values='ATP'</code> but I need to be able loop through all columns. </p>

<p>Any guidance? Is this even the best approach?</p>

<p>Thanks in advance. </p>