I have this column in a df:
> df["time"]
0 2007-02-01 22:00:00+00:00
1 2007-02-01 22:00:00+00:00
2 2007-02-01 22:00:00+00:00
3 2007-02-01 22:00:00+00:00
4 2007-02-01 22:00:00+00:00
I want to create three new columns with day, month, and year but I can't figure out a way to extract each one of these of the time column
.
In order to not modify your existing
time
column, create a separate datetime series usingpd.to_datetime
and then use thedt
accessor:An alternative would be to use
str.split('-')
on thedatetime.dt.date
series: