title: How to convert a dataframe into a 2D array in-order to run some calculations?
body: <p>I have the following pandas dataframe:</p>
  
  <pre><code>             timestamp     close
  .. .......... ........  ........
  86 2017-03-12 14:00:00  0.000077
  87 2017-03-12 16:00:00  0.000076
  88 2017-03-12 18:00:00  0.000074
  89 2017-03-12 20:00:00  0.000073
  90 2017-03-12 22:00:00  0.000077
  .. .......... ........  ........
  </code></pre>
  
  <p>I have prototyped some <code>tangent</code> and <code>curvature</code> calculations that work with the following data:</p>
  
  <pre><code>np.array([[0.0, 0.0], [0.13216, 0.11837], [0.25379, 0.05027], ... ])
  </code></pre>
  
  <p>How can I construct a numpy array from the data frame as a 2D data, just like the array above? I guess, the <code>close</code> data will be the <code>Y</code> axis, and the dates will be the <code>X</code> data, maybe something like this: <code>0, 0.1, 0.2, 0.3 ...</code> as they are equally spaced date-time objects? So, probably something like this:</p>
  
  <pre><code>np.array([[0.0, 0.000077], [0.1, 0.000076], [0.2, 0.05027], [0.3, 0.000074], ... ])
  </code></pre>
  
  <p>Then once I do the calculation, which will yield a float number, I will need to add it back into the pandas data-frame and make sure it lines-up with the timestamp.</p>
  
  <pre><code>             timestamp     close change
  .. .......... ........  ........ ......
  86 2017-03-12 14:00:00  0.000077 0.00345
  87 2017-03-12 16:00:00  0.000076 0.64477
  88 2017-03-12 18:00:00  0.000074 0.32356
  89 2017-03-12 20:00:00  0.000073 0.13331
  90 2017-03-12 22:00:00  0.000077 0.66436
  .. .......... ........  ........ .......
  </code></pre>
  
  <p>I probably will be able to do that by dissecting the dataframe, run some for loops to construct the array and do the same in reverse to inject the new column into the pandas dataframe. However, I am interested to learn if there is an elegant way for doing this.</p>
  
  <p><em>--- (CLARIFICATION) ---</em></p>
  
  <p>So I am not after the actual calculations. I already know how to perform those. But my function expects a <strong>2D</strong> array as in <strong>X</strong>, <strong>Y</strong> values. So I need to convert the <code>date</code> column into <strong>X</strong> values and then store the <code>close</code> column as the <strong>Y</strong> value. So that I can run it through my calculation. Then the output will be an array of float numbers. I will need to inject everyone of those floats into a new column inside my pandas dataframe. And when doing that, I will need to make sure that each value matches the correct date row.</p>