0

I have a dataframe with a datetime column dt with the dtype datetime64[ns, US/Eastern].

I am trying to find all rows with the time 2023-01-01 12:00:00-05:00.

I tried to do this:

eastern = pytz.timezone('US/Eastern')
query_dt = datetime.datetime(year=2023, month=1, day=1, hour=12, minute=0, tzinfo=eastern)
df_sub = df[df.dt == query_dt]

But this is telling me there are no rows corresponding to query_dt, which is not correct as I can clearly see there are rows with that time.

24n8
  • 1,898
  • 1
  • 12
  • 25
  • Hi. Do you mind providing your `df.head(2).to_dict()` ? – rafaelc Jun 02 '23 at 18:56
  • @rafaelc yeah it is `{0: Timestamp('2022-12-01 09:45:00-0500', tz='US/Eastern'), 1: Timestamp('2022-12-01 10:00:00-0500', tz='US/Eastern')}` – 24n8 Jun 02 '23 at 19:05
  • IIRC, using `pytz` in the standard `datetime` constructor is buggy. We had questions about that before, let me find one – rafaelc Jun 02 '23 at 19:19

0 Answers0