Skip to content
Advertisement

Converting datetime only to time in pandas

I would like to ask a question regarding converting datetime only to time. I have values ‘Date Created” that include Dates and Times in one column and I would like to create two columns: one with only Date and one with Time. I wrote a code but in Time column I got a default date of 1900-01-01 along with time.

I wonder now how I could create a column only with Time in format: Hours:Minutes:Seconds

I will be grateful for any tips.

JavaScript

I wrote a code like the one below to extract dat

JavaScript

Advertisement

Answer

pandas has no separate datatypes for date and time. if you only want your columns to show date or time resp., you could format to string (strftime). Ex:

JavaScript

Python documentation / strftime

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement