I want to convert a column to type date time. Some of the date are invalid, and I want to get rid of them. Here's what I have right now
df_event['event_date'] = try: pd.to_datetime(df_event['event_date']) except ValueError as e: pass
It says this is invalid syntax. What would be the correct syntax here? Moreover, for this piece of code, I'm trying to convert first, then I'll drop the rows where the value is not date time. Is there a way to drop the invalid rows direcrly in one step?