0

I have a csv file having the following with a Date columns having the following format 2002-08-31 so YEAR-MONTH-DAY.

I would like to split this columns in 3 different columns in such a way that the table will have a YEAR column a MONTH column and a DAY column. Does anyone knows how to achieve that

steve
  • 511
  • 1
  • 9
  • 33

1 Answers1

1

If you use Pandas 0.15 or above, you can take advantage of the dtaccessor like this

df['Year'] = df['Date'].year
df['Month'] = df['Date'].month
df['Day'] = df['Date'].day
Tasos
  • 7,325
  • 18
  • 83
  • 176