I am doing a Pandas operation on all rows using lambda function
match = re.compile(r"([\d]{2,4}[-|/][\d]{1,2}[-|/][\d]{2,4})")
date_to_month = lambda x: pd.to_datetime(x.group(0)).strftime("%B")
data["path"] = data["path"].str.replace(match, date_to_month, regex=True)
The dataframe is so large and for a particular row I am getting the following error:
DateParseError: Invalid date specified (17/25)
I tried to add try except like below:
try:
match = re.compile(r"([\d]{2,4}[-|/][\d]{1,2}[-|/][\d]{2,4})")
date_to_month = lambda x: pd.to_datetime(x.group(0)).strftime("%B")
data["path"] = data["path"].str.replace(match, date_to_month, regex=True)
except:
pass
Now this will pass the error. The problem is just one row is causing this error and all other rows are affected by this as this operation won't happen on other rows.
Is there a way by which we can skip the rows which throw error on executing without affecting the operation on other rows?