How to convert miliseconds to datetime with format: mm:ss:msmsms (minutes:seconds:miliseconds) without year , month an day [duplicate]
How to convert miliseconds to datetime with format: mm:ss:msmsms (minutes:seconds:miliseconds) without year , month an day [duplicate]
This question already has an answer here:
Is there a simple way to convert milliseconds in a dataframe to a datetime without year, month and day?
I have successfully converted a column of milliseconds to datetime. However, I want to get rid of the year, months and days.
I did this:
df['Laptimes'] = pd.to_datetime(df['milliseconds'], unit='ms')
But my values are now formatted as: "1970-01-01 00:01:38.109"
.
"1970-01-01 00:01:38.109"
I want to have: "01:38:109"
"01:38:109"
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1 Answer
1
Just call the time() method on the datetime object:
df['Laptimes'].time()
docs.python.org/2/library/datetime.html#datetime.date.strftime and docs.python.org/2/library/…
– Joe
Aug 21 at 13:22