I have column date values as below in the dataframe
Jan 2009
Feb 2003
2017-09-01 00:00:00
but when I use
np.where(df['Date'].astype(str).apply(len) == 8,pd.to_datetime(df['Date'],format="%b %Y"),pd.to_datetime(df['Date']))
it fails with the below error:-
ValueError: time data datetime.datetime(2017, 9, 1, 0, 0) does not match format '%b %Y' (match)
Any ideas?