-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Fixes for #16896(TimedeltaIndex indexing regression for strings) #16907
Changes from 1 commit
e163de1
2be2156
f65c018
21b5bd2
dcb274d
7d89c19
3d36695
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,12 +199,15 @@ def test_is_datetime64tz_dtype(): | |
|
||
def test_is_timedelta64_dtype(): | ||
assert not com.is_timedelta64_dtype(object) | ||
assert not com.is_timedelta64_dtype(None) | ||
assert not com.is_timedelta64_dtype([1, 2, 3]) | ||
assert not com.is_timedelta64_dtype(np.array([], dtype=np.datetime64)) | ||
assert com.is_timedelta64_dtype(np.timedelta64) | ||
assert com.is_timedelta64_dtype(pd.Series([], dtype="timedelta64[ns]")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also can you add: |
||
|
||
assert not com.is_timedelta64_dtype('0 days') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. silly but can you group all of the assert not ones together (IIRC pattern is to have them first) |
||
assert not com.is_timedelta64_dtype("0 days 00:00:00") | ||
assert not com.is_timedelta64_dtype(["0 days 00:00:00"]) | ||
assert not com.is_timedelta64_dtype("NO DATE") | ||
|
||
|
||
def test_is_period_dtype(): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,9 @@ def test_list_like_indexing(self, indexer, expected): | |
dtype="int64") | ||
|
||
tm.assert_frame_equal(expected, df) | ||
|
||
def test_string_indexing(self): | ||
df = pd.DataFrame({'x': range(3)}, index=pd.to_timedelta(range(3), unit='days')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add the issue number here |
||
expected = df.iloc[0] | ||
sliced = df.loc['0 days'] | ||
tm.assert_series_equal(sliced, expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you be a bit more explicty (e.g. say indexing with a string when you have a TimedeltaIndex)