I am new to Python, I have a file having date column as below formats:
date = pd.Series(['10-21-2012 ', '7-18-2019 ', '02-2-2008',
'2010/21/4 ', '11-8-2019 '])
I used the following code to get the month but I get an error:
ValueError: month must be in 1..12
Code:
pd.to_datetime(date).dt.month
The output should be
10
7
02
4
11
Please can someone help me with this?