How to take only the time of a Timestamp

Asked

Viewed 219 times

0

Using the command below:

pd.to_datetime(1490195805, unit='s')

The return is:

Timestamp('2017-03-22 15:16:45')

How do I extract only the time: 15:16:45?

  • Hi, use the datetime... datetime.strftime(pd.to_datetime(1490195805, unit='s'), format="%H:%M:%S")

  • This answers your question? Convert timestamp to date/time

  • If you do not need to use pandas, the question suggested above should already suit your case (just adapt what you have there - in particular this answer - to show time fields only)

1 answer

2


You can do with the time function:

import pandas as pd

a = pd.to_datetime(1490195805, unit='s')
str(a.time())

Exit:

'15:16:45'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.