-2

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".

I want to have: "01:38:109"

Niels Hoogeveen
  • 365
  • 4
  • 19
  • https://docs.python.org/2/library/datetime.html#datetime.date.strftime and https://docs.python.org/2/library/datetime.html#strftime-strptime-behavior – Joe Aug 21 '18 at 13:22

1 Answers1

0

Just call the time() method on the datetime object:

df['Laptimes'].time()
Hkoof
  • 756
  • 5
  • 14