Convert range to timestamp in Pandas
<p>I have a column in a pandas data frame that goes from 0 to 172800000 in steps of 10. I would like to convert into datetime stamp with a specified date, beginning at midnight of that day. </p>

<p>So, suppose, </p>

<pre><code>time = np.arange(0,172800000, 10)
</code></pre>

<p>I would like to convert this in the following format: </p>

<pre><code>YYYY-MM-DD: HH:MM:SS.XXX
</code></pre>

<p>The starting date should be <strong>2016-09-20</strong>. </p>

<p>Here's what I have done: </p>

<pre><code># Create a dummy frame as an example: 
test = pd.DataFrame()
time = np.arange(0, 172800000, 10)
test['TIME'] = time
data = np.random.randint(0, 1000, size=len(time))
test['DATA'] = data

# Convert time to datetime:
test['TIME'] = pd.to_datetime(test['TIME'], unit='ms') 
</code></pre>

<p>If I check the head of the data frame, I get the following: </p>

<pre><code>             TIME           DATA
0   1970-01-01 00:00:00.000 681
1   1970-01-01 00:00:00.010 986
2   1970-01-01 00:00:00.020 957
3   1970-01-01 00:00:00.030 422
4   1970-01-01 00:00:00.040 319
</code></pre>

<p>How do I get the year, month, and day to start on 2016, 09, 20 and not 1970?</p>

<p>Try:</p>

<pre><code>test['TIME'] = pd.to_datetime('2016-09-20') + pd.to_timedelta(time, 'ms')
</code></pre>

python pandas