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 2 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 @@ -452,6 +452,17 @@ def test_get_loc_reasonable_key_error(self):
with pytest.raises(KeyError, match="2000"):
index.get_loc("1/1/2000")

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (not a blocker), can you put this a few tests up adjacent to the other tests that use the method kwarg

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks


class TestDatetimeIndex:
@pytest.mark.parametrize(
Expand Down