How to extract tuple values in pandas dataframe for use of matplotlib?
<p>I have the following dataframe:</p>

<pre><code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
x = np.concatenate((x,x))
y = []
for i in range(2):
    y.append(np.random.random_integers(0,10,20))

d = {'A': [(x[i], y[0][i]) for i in range(20)],
    'B': [(x[i], y[1][i]) for i in range(20)]} 
df = pd.DataFrame(d, index = list('aaaaaaaaaabbbbbbbbbb'))
</code></pre>

<p>df</p>

<pre><code>    A        B
a  (0, 2)  (0, 10)
a  (1, 0)   (1, 8)
a  (2, 3)   (2, 8)
a  (3, 7)   (3, 8)
a  (4, 8)  (4, 10)
a  (5, 2)   (5, 0)
a  (6, 1)   (6, 4)
a  (7, 3)   (7, 9)
a  (8, 4)   (8, 4)
a  (9, 4)  (9, 10)
b  (0, 0)   (0, 3)
b  (1, 2)  (1, 10)
b  (2, 8)   (2, 3)
b  (3, 1)   (3, 7)
b  (4, 6)   (4, 1)
b  (5, 8)   (5, 3)
b  (6, 1)   (6, 4)
b  (7, 1)   (7, 1)
b  (8, 2)   (8, 7)
b  (9, 9)   (9, 3)
</code></pre>

<p>How do I make the following plots?</p>

<p>Plot 1 is on column 'A', 2 lines (one line for index = a, the other for index = b), x values are the first elements of the tuples. y values are the 2nd elements of the tuple.</p>

<p>Plot 2 is on column'B', the rest is the same as plot 1.</p>

<p>I cannot figure out how I can extract values from the tuples in the dataframe.</p>

<p>In addition, will groupby be helpful in this case?</p>

<p>In reality, I have about a thousand columns of data, 5 groups, each group ~500 rows. So I'm looking for a quick way to solve this (dataframe size ~2500 x 1000)</p>

<p>Thanks a lot</p>