Simple index on DATE and TIME columns
<p>I have a CSV containing data that looks like this:</p>

<pre><code>&lt;DATE&gt;      &lt;TIME&gt;    &lt;OPEN&gt;  &lt;LOW&gt;  &lt;HIGH&gt;  &lt;CLOSE&gt;  
2001-01-03  00:00:00  0.9507  0.9505  0.9509  0.9506  
....   
2015-05-13  02:00:00  0.9496  0.9495  0.9509  0.9505
</code></pre>

<p>I want to create an index on &lt;DATE> and &lt;TIME> but retain the two columns as normal columns so I can reference them. </p>

<p>As the data is stored in a CSV I am not sure how I could parse the 2 columns (DATE and TIME) into one before creating the dataframe. </p>

<p>I've had a look at many answers but they seems convoluted for what I am trying to do, and I have became convinced I am missing the simple solution</p>

<pre><code>Context around what lead me to this:
</code></pre>

<p>The proper way I've identified setting a new value (for when I am computing rolling mean values) is:</p>

<pre><code>df.set_value('index', 'column', value)
</code></pre>

<p>Because my index is currently just on date, referencing the index for a particular row (say, the 1st row) means many values are set instead of one</p>

<p><strong>UPDATE:</strong></p>

<pre><code>In [170]: df = pd.read_csv('/path/to/file.csv', parse_dates={'TIMESTAMP': ['DATE','TIME']}).set_index('TIMESTAMP')

In [171]: df
Out[171]:
                       OPEN     LOW    HIGH   CLOSE
TIMESTAMP
2001-01-03 00:00:00  0.9507  0.9505  0.9509  0.9506
2001-01-03 01:00:00  0.9507  0.9505  0.9509  0.9506
2001-01-03 02:00:00  0.9507  0.9505  0.9509  0.9506
2001-01-03 03:00:00  0.9507  0.9505  0.9509  0.9506
2001-01-03 04:00:00  0.9507  0.9505  0.9509  0.9506
2001-01-04 00:00:00  0.9507  0.9505  0.9509  0.9506
2001-01-04 01:00:00  0.9507  0.9505  0.9509  0.9506
2001-01-04 02:00:00  0.9507  0.9505  0.9509  0.9506

In [172]: df.index.dtype
Out[172]: dtype('&lt;M8[ns]')
</code></pre>

<p><strong>OLD answer:</strong></p>

<p>you can do it this way:</p>

<pre><code>In [155]: df
Out[155]:
   a  b  c
0  0  0  3
1  1  2  0
2  2  2  3
3  1  0  0
4  1  3  2
5  4  0  1
6  2  0  3
7  2  1  2
8  3  3  4
9  0  0  3

In [156]: df.join(df.ix[:, :2], rsuffix='_idx').set_index((df.ix[:, :2].columns + '_idx').tolist())
Out[156]:
             a  b  c
a_idx b_idx
0     0      0  0  3
1     2      1  2  0
2     2      2  2  3
1     0      1  0  0
      3      1  3  2
4     0      4  0  1
2     0      2  0  3
      1      2  1  2
3     3      3  3  4
0     0      0  0  3
</code></pre>

<p>BUT, you don't really need it, because it's redundant - you still have your data in the index and can use it...</p>

python pandas numpy dataframe