How do I pass errors='coerce' to pd.to_datetime from pd.read_excel in Pandas?

Viewed 410

I'm having an issue converting some date fields when using pd.read_excel

cols_A8_J2007[i] = pd.read_excel(i, ('sheet'+str(j)), headers = 1, skiprows = 6, nrows=2000, usecols = 'A:J', converters = {'Expired': pd.to_datetime, 'Valid Until': pd.to_datetime})

I'd like to be able to pass errors='coerce' when the function is called, but I'm not sure how to do that as I only pass the function; so there must be some other argument to read_excel I have to pass in order to pass that when pd.to_datetime is called.

Pandas error trying to convert string into integer

0 Answers
Related