I have df like this:
df['Time']
2017-08-06 11:00:00+00:00
2017-08-08 15:00:00+00:00
2017-08-10 04:00:00+00:00
2017-08-12 23:00:00+00:00
2017-08-08 15:00:00+00:00
I want to slice it with condition
mask1=df['Time'] > datetime.datetime.strptime('2017-08-12', "%Y-%m-%d")
I get an error like
can't compare offset-naive and offset-aware datetimes
Somehow I have to convert df['Time']
to offset-naive.
Please help me fix this.
It seems you need:
df['Time'] = df['Time'].dt.tz_localize(None)
Or:
df['Time'] = df['Time'].dt.tz_convert(None)
Or:
df['Time'] = df['Time'].astype('datetime64[ns]')
See also tz aware dtypes
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With