Use pd.to_datetime
with parameter errors='coerce'
to make non-dates into NaT
null values. Then you can drop those rows
df['Date'] = pd.to_datetime(df['Date'], errors='coerce')
df = df.dropna(subset=['Date'])
df
Use pd.to_datetime
with parameter errors='coerce'
to make non-dates into NaT
null values. Then you can drop those rows
df['Date'] = pd.to_datetime(df['Date'], errors='coerce')
df = df.dropna(subset=['Date'])
df
For further actions, you may consider blocking this person and/or reporting abuse
Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.
Vitali Sorenko -
Negrito 👌 -
kallileiser -
Ahmend Riss -
Top comments (0)