Python Pandas split Date in day month year and hour

Skip Montanaro skip.montanaro at gmail.com
Wed Aug 19 16:05:53 EDT 2020


> I would like know how can I get for this array the values for day, month
> and hour:
>
> 2017-11-01 03:00:00       year = 2017      month = 11    day = 1    and
>     hour = 3

Pandas has a datetime type. You should probably be using it. It's been
awhile (a year at least), but if your datetime column is filled with
datetime types, you should be able to append columns to your DataFrame
which correspond to individual components of the datetime instances.
Don't be looking outside of Pandas to Python's time or datetime
module.

Skip


More information about the Python-list mailing list