Skip to content

Commit 47a215e

Browse files
Backport PR #32152 on branch 1.0.x (TST: add test for get_loc on tz-aware DatetimeIndex) (#32160)
1 parent 9c95e16 commit 47a215e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pandas/tests/indexes/datetimes/test_indexing.py

+13
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,19 @@ def test_take_fill_value_with_timezone(self):
343343
idx.take(np.array([1, -5]))
344344

345345

346+
class TestGetLoc:
347+
def test_get_loc_tz_aware(self):
348+
# https://github.com/pandas-dev/pandas/issues/32140
349+
dti = pd.date_range(
350+
pd.Timestamp("2019-12-12 00:00:00", tz="US/Eastern"),
351+
pd.Timestamp("2019-12-13 00:00:00", tz="US/Eastern"),
352+
freq="5s",
353+
)
354+
key = pd.Timestamp("2019-12-12 10:19:25", tz="US/Eastern")
355+
result = dti.get_loc(key, method="nearest")
356+
assert result == 7433
357+
358+
346359
class TestDatetimeIndex:
347360
@pytest.mark.parametrize(
348361
"null", [None, np.nan, np.datetime64("NaT"), pd.NaT, pd.NA]

0 commit comments

Comments
 (0)