I have gone through a lot of forums and discussions. However, can't get my problem solved.
Note: 'Released' column has same format for all entries and there are no null values or unwanted spaces in it.
I am working on data-set Google Play Store Apps (csv). It contains the 'Released' column having the date of release, in string type. I want to convert to date format, so that I can calculate how many years that app has been on the store. Data-set has the date stored in string type and has the format as follows.
Mar 7, 2016 sep 24, 2016 Jan 10, 2018 Jan 13, 2020 Dec 6, 2012
When I pick a specific date string, my code converts it to the respective date format. But, when I apply the same code to full column, I get the error
# This code executes fine and converts the string to date. s = 'Mar 7, 2016' d = dt.datetime.strptime(s, '%b %d, %Y') print(d.strftime('%d-%m-%y')) # When same code applies to column, it gives the error "time data '0' does not match format %b %d, %Y" d = df['Released'].apply(lambda x: dt.datetime.strptime(x, '%b %d, %Y')) # This code gives the error, "day is out of range for month: 0" d = pd.to_datetime(df['Released']).strptime('%b %d, %Y') # This code does not give any error, however, converts all the dates to NAT. d = pd.to_datetime(df['Released'], format='%d-%m-%y', errors='coerce')
I have also tried arrow and dateutil libraries, they also work fine on single date. However, whenever I give them the series/column of data-frame they both give the same error as I have mentioned above.