Iterating over columns with for loops in pandas dataframe
<p>I am trying to take a dataframe read in from CSV file, and generate scatter plots for each column within the dataframe. For example, I have read in the following with <code>df=pandas.readcsv()</code></p>

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

<p>I would like to generate a scatter plot using sample as the x values, and the areas for each of the columns.</p>

<p>I am using the following code with bokeh.plotting to plot each column manually</p>

<pre><code>import pandas
from bokeh.plotting import figure, show

df = pandas.read_csv("data.csv")
p = figure(x_axis_label='Sample', y_axis_label='Peak Area', x_range=sorted(set(df['Sample'])))
p.scatter(df['Sample'], df['AMP'])
show(p)
</code></pre>

<p>This generates scatter plots successfully, but I would like to create a loop to generate a scatter plot for each column. In my full dataset, I have over 500 columns I would like to plot.</p>

<p>I have followed references for using df.iteritems and df.itertuples for iterating through dataframes, but I'm not sure how to get the output I want. </p>

<p>I have tried the following:</p>

<pre><code>for index, row in df.iteritems():
    p = figure()
    p.scatter(df['Sample'], df[row])
    show(p)
</code></pre>

<p>I hit an error right away:</p>

<blockquote>
  <p>raise KeyError('%s not in index' % objarr[mask] KeyError: "['1A' '1B'
  '2A' '2B'] not in index</p>
</blockquote>

<p>Any guidance? Thanks in advance.</p>