I have one column called published (date). As you can see, it has multiple date formats and also nan values. I would like to skip nan values, convert all the other formats to %Y-%-%d, and ignore the one that has the only year.
I tried df['publish_time']=pd.to_datetime(df['publish_time']) and also things like:
fmt=['%Y-%m-%d', '%d-%m-%Y', '%d/%m/%Y',
'%Y-%d-%m', '%Y-%d-%b', '%d-%b-%Y', '%d/%b/%Y','Year: %d; month','month:
%d;Year','%Y','%b %d %Y','%b %Y %d']
but I could not solve it. Any suggestions? Thanks!
Here is that column:
published
2014 Jul 22
2003 Aug
2019 Nov 26
2012-12-07
2020 Jan 21
2015-01-01
2010-11-30
2007-05-10
2020
2012-02-29
2016 Apr 19
2006-12-31
2013 Jun 27
2019 Jun 19
2015 Jun 12
2006 Jun-Dec
2006-07-31
nan
2017-04-15
2016 May 22
2020 Feb
2017 May 6
2020 Mar 11
2013-04-30
2020-03-07
nan
2018