I'm trying to change one column of a pandas dataframe from a format like this: 162000
to 16:20:00
(%H%M%S)
I've tried this:
t = mydataframe['column name']
pd.to_datetime(t, format='%H%M%S')
But I get this error:
TypeError: 'long' object is unsliceable
However if I don't use the format parameter I get this:
1970-01-01 00:00:00.000162000
What's going on here?
EDIT:
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, ...
EDIT2:
Ok, restarting the kernel of the notebook, solved that issue! Computers eh? :D
Ok, now I have this format:
1900-01-01 16:20:00
How can I change this so, that the to_datetime gives me only 16:20:00
?
EDIT3:
Got it! Btw, the answer for my second question is here: How to change the datetime format in pandas