Skip to content

TST: add test for get_loc on tz-aware DatetimeIndex #32152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pandas/tests/indexes/datetimes/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,17 @@ def test_get_loc(self):
with pytest.raises(NotImplementedError):
idx.get_loc(time(12, 30), method="pad")

def test_get_loc_tz_aware(self):
# https://github.com/pandas-dev/pandas/issues/32140
dti = pd.date_range(
pd.Timestamp("2019-12-12 00:00:00", tz="US/Eastern"),
pd.Timestamp("2019-12-13 00:00:00", tz="US/Eastern"),
freq="5s",
)
key = pd.Timestamp("2019-12-12 10:19:25", tz="US/Eastern")
result = dti.get_loc(key, method="nearest")
assert result == 7433

def test_get_loc_nat(self):
# GH#20464
index = DatetimeIndex(["1/3/2000", "NaT"])
Expand Down