8000 BUG: TimedeltaIndex raising ValueError when slice indexing (#16637) by jdeschenes · Pull Request #16638 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

BUG: TimedeltaIndex raising ValueError when slice indexing (#16637) #16638

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 13 commits into from
Jul 6, 2017
Prev Previous commit
Next Next commit
Changes based on review comments
* Fixed bug on windows with int32/int64 confusion
* Added unit_test to is_timedelta64_dtype when a string is passed
* Changed unit_test name from `test_slice_indexing` to `test_list_like_indexing`
  • Loading branch information
Jean-Mathieu Deschenes committed Jul 4, 2017
commit d842230f13b086777117305eeb5f5da37b3a667c
2 changes: 2 additions & 0 deletions pandas/tests/dtypes/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ def test_is_timedelta64_dtype():
assert com.is_timedelta64_dtype(np.timedelta64)
assert com.is_timedelta64_dtype(pd.Series([], dtype="timedelta64[ns]"))

assert not com.is_timedelta64_dtype("0 days 00:00:00")
Copy link
Contributor

Choose a reason for hiding this comment

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

didn't you have 2 cases that trigger the exception? if so pls add the other one.

Copy link
Contributor Author
@jdeschenes jdeschenes Jun 9, 2017

Choose a reason for hiding this comment

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

Not that I am aware of. There is a separate issue I think were isnull would trigger an exception in the get_loc function. I don't see how that condition could be hit in the future.



def test_is_period_dtype():
assert not com.is_period_dtype(object)
Expand Down
7 changes: 4 additions & 3 deletions pandas/tests/indexing/test_timedelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ def test_boolean_indexing(self):
[0, 1, 2, 10, 4, 5, 6, 7, 8, 9],
[10, 10, 10, 3, 4, 5, 6, 7, 8, 9]]
for cond, data in zip(conditions, expected_data):
result = df.assign(x=df.mask(cond, 10).astype(df['x'].dtype))
result = df.assign(x=df.mask(cond, 10).astype('int64'))
expected = pd.DataFrame(data,
index=pd.to_timedelta(range(10), unit='s'),
columns=['x'])
columns=['x'],
dtype='int64')
tm.assert_frame_equal(expected, result)

Copy link
Contributor

Choose a reason for hiding this comment

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

just make sure test is near other slicing testsing (may not actually be many).

def test_slice_indexing(self):
def test_list_like_indexing(self):
# GH 16637
df = pd.DataFrame({'x': range(10)})
df.index = pd.to_timedelta(range(10), unit='s')
Expand Down
0