Skip to content

Commit d171c87

Browse files
TST: add test for get_loc on tz-aware DatetimeIndex (#32152)
1 parent 4a05601 commit d171c87

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/indexes/datetimes/test_indexing.py

+11
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,17 @@ def test_get_loc(self):
423423
with pytest.raises(NotImplementedError):
424424
idx.get_loc(time(12, 30), method="pad")
425425

426+
def test_get_loc_tz_aware(self):
427+
# https://github.com/pandas-dev/pandas/issues/32140
428+
dti = pd.date_range(
429+
pd.Timestamp("2019-12-12 00:00:00", tz="US/Eastern"),
430+
pd.Timestamp("2019-12-13 00:00:00", tz="US/Eastern"),
431+
freq="5s",
432+
)
433+
key = pd.Timestamp("2019-12-12 10:19:25", tz="US/Eastern")
434+
result = dti.get_loc(key, method="nearest")
435+
assert result == 7433
436+
426437
def test_get_loc_nat(self):
427438
# GH#20464
428439
index = DatetimeIndex(["1/3/2000", "NaT"])

0 commit comments

Comments
 (0)