Plotting (and saving) specific cells from multiple dataframe in Pandas
<p>For example, if I have 3 dataframes like this:</p>

<pre><code>In [1]: df1 = pd.DataFrame({'A': ['32', '36', '40', '33'],
   ...:                     'B': ['32', '34', '39', '35'],
   ...:                     'C': ['34', '32', '35', '36'],
   ...:                     'D': ['35', '39', '42', '40']},
   ...:                     index=[0, 1, 2, 3])
   ...: 

In [2]: df2 = pd.DataFrame({'A': ['33', '36', '37', '40'],
   ...:                     'B': ['42', '43', '46', '39'],
   ...:                     'C': ['34', '36', '38', '40'],
   ...:                     'D': ['32', '35', '34', '37']},
   ...:                      index=[0, 1, 2, 3])
   ...: 

In [3]: df3 = pd.DataFrame({'A': ['38', '39', '40', '41'],
   ...:                     'B': ['38', '37', '41', '40'],
   ...:                     'C': ['36', '39', '42', '41'],
   ...:                     'D': ['34', '39', '37', '39']},
   ...:                     index=[0, 1, 2, 3])
</code></pre>

<p>How if I want to plot specific cells from those 3 dataframe? For example, I want to plot the cell in the first row and first column from those dataframe, to see the trend.
To access it one by one using iloc is seem so lame, especially with more dataframes (actually I have 33 dataframes imported from csv, with 600 columns and 400 rows each)
Is there any way doing it easier than iloc?</p>

<p><strong><em>Option 1</em></strong></p>

<p>The most general solution to your question would be to wrap your dataframes into a <code>pandas.Panel</code></p>

<pre><code>pnl = pd.Panel({'df1': df1, 'df2': df2, 'df3': df3})[['df1', 'df2', 'df3']]
</code></pre>

<p>Then you could access the desired series</p>

<pre><code>pnl.iloc[:, 0, 0]

df1    32
df2    33
df3    38
Name: A, dtype: object
</code></pre>

<hr>

<p><strong><em>Option 2</em></strong></p>

<p>you could also drop the dataframes into another dataframe</p>

<pre><code>df = pd.concat([d.stack() for d in [df1, df2, df3]],
               axis=1, keys=['df1', 'df2', 'df3'])
</code></pre>

<p>Then access the specific data with</p>

<pre><code>df.iloc[0, :]

df1    32
df2    33
df3    38
Name: (0, A), dtype: object
</code></pre>

<p>Or</p>

<pre><code>df.to_panel().iloc[:, 0, 0]

df1    32
df2    33
df3    38
Name: A, dtype: object
</code></pre>

<hr>

<p><strong><em>Option 3</em></strong></p>

<p>You can just grab the 3 items and wrap it in a <code>panda.Series</code></p>

<pre><code>pd.Series([d.iloc[0, 0] for d in [df1, df2, df3]])

0    32
1    33
2    38
dtype: object
</code></pre>

python pandas dataframe