YeiBi
YeiBi

Reputation: 55

How to filter the date column in pandas?

I want to remove the date in the column['DATE'] and use the quickfilter.

I do this:

quickfilter = (df_dexu.DATE < 2018-12-1)
df_dexu=df_dexu[quickfilter]

but it gives the error message:

TypeError: invalid type comparison

Upvotes: 1

Views: 54

Answers (1)

jezrael
jezrael

Reputation: 862441

Try convert column to_datetime:

quickfilter = (pd.to_datetime(df_dexu.DATE) < '2018-12-01')

Or:

df_dexu.DATE = pd.to_datetime(df_dexu.DATE)
quickfilter = (df_dexu.DATE < '2018-12-01')

Upvotes: 2

Related Questions