title: Pandas - image to DataFrame
body: <p>I want to convert an RGB image into a DataFrame, so that I have the co-ordinates of each pixel and their RGB value.</p>
  
  <pre><code>         x   y   red  green  blue
  0        0   0   154      0     0
  1        1   0   149    111     0
  2        2   0   153      0     5
  3        0   1   154      0     9
  4        1   1   154     10    10
  5        2   1   154      0     0
  </code></pre>
  
  <p>I can extract the RGB into a DataFrame quite easily</p>
  
  <pre><code>colourImg = Image.open("test.png")
  colourPixels = colourImg.convert("RGB")
  colourArray = np.array(colourPixels.getdata())
  
  df = pd.DataFrame(colourArray, columns=["red","green","blue"])
  </code></pre>
  
  <p>But I don't know how to get the X &amp; Y coordinates in there.  I <em>could</em> write a loop, but on a large image that takes a long time.</p>