Turning column of a pandas dataframe from 4 digits to a time
<p>I'm trying to change one column of a pandas dataframe from a format like this: <code>162000</code> to <code>16:20:00</code> (%H%M%S)</p>

<p>I've tried this:</p>

<pre><code>t = mydataframe['column name']
pd.to_datetime(t, format='%H%M%S')
</code></pre>

<p>But I get this error: </p>

<pre><code>TypeError: 'long' object is unsliceable
</code></pre>

<p>However if I don't use the format parameter I get this:</p>

<pre><code>1970-01-01 00:00:00.000162000
</code></pre>

<p>What's going on here?</p>

<p><strong>EDIT:</strong></p>

<pre><code>t.dtype
Name: column name, dtype: int64

print t.head(5)
0    162000
1    161200
2    162400
3    163600
4    164800

t.to_dict()
{0: 162000,
 1: 161200,
 2: 162400,
 3: 163600,
 4: 164800, ...
</code></pre>

<p><strong>EDIT2:</strong></p>

<p>Ok, restarting the kernel of the notebook, solved that issue! Computers eh? :D</p>

<p>Ok, now I have this format:</p>

<pre><code>1900-01-01 16:20:00
</code></pre>

<p>How can I change this so, that the to_datetime gives me only <code>16:20:00</code> ?</p>

<p><strong>EDIT3:</strong></p>

<p>Got it! Btw, the answer for my second question is here: <a href="https://stackoverflow.com/questions/38067704/how-to-change-the-datetime-format-in-pandas">How to change the datetime format in pandas</a></p>