I'm trying to extract year/date/month info from the 'date' column in the pandas dataframe. Here is my sample code:
from datetime import datetime
def date_split(calendar):
for row in calendar:
new_calendar={}
listdate=datetime.strptime(row['date'],'%Y-%M-%D')
I haven't finished the complete code, but when I test run this part I keep getting error like this:
----> 7 listdate=datetime.strptime(row['date'],'%Y-%M-%D')
TypeError: string indices must be integers
Anyone has any idea?
Btw, this is the dataframe I use (calendar_data):