From a88da5aafbcaae3064cc8b18ee1ed45bdec8de68 Mon Sep 17 00:00:00 2001 From: Jean-Mathieu Deschenes Date: Fri, 9 Jun 2017 11:28:03 -0400 Subject: [PATCH] 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` --- pandas/tests/dtypes/test_common.py | 2 ++ pandas/tests/indexing/test_timedelta.py | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pandas/tests/dtypes/test_common.py b/pandas/tests/dtypes/test_common.py index 4633dde5ed5371..326ff7119949c3 100644 --- a/pandas/tests/dtypes/test_common.py +++ b/pandas/tests/dtypes/test_common.py @@ -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") + def test_is_period_dtype(): assert not com.is_period_dtype(object) diff --git a/pandas/tests/indexing/test_timedelta.py b/pandas/tests/indexing/test_timedelta.py index 80c9889a0fa523..050c9c45ca66a7 100644 --- a/pandas/tests/indexing/test_timedelta.py +++ b/pandas/tests/indexing/test_timedelta.py @@ -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) - 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')