From cdb539bd708f1bc0d2277024341071184f9ab5a6 Mon Sep 17 00:00:00 2001 From: Chang She Date: Fri, 2 Nov 2012 13:34:53 -0400 Subject: [PATCH] BUG: exclude timedelta64 from integer dtypes #2146 --- pandas/core/common.py | 5 ++++- pandas/tests/test_format.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pandas/core/common.py b/pandas/core/common.py index c52de85670c5e..a4d7d1bf9a898 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -90,6 +90,8 @@ def _isnull_ndarraylike(obj): elif values.dtype == np.dtype('M8[ns]'): # this is the NaT pattern result = values.view('i8') == lib.iNaT + elif issubclass(values.dtype.type, np.timedelta64): + result = -np.isfinite(values.view('i8')) else: result = -np.isfinite(obj) return result @@ -800,7 +802,8 @@ def is_integer_dtype(arr_or_dtype): else: tipo = arr_or_dtype.dtype.type return (issubclass(tipo, np.integer) and not - issubclass(tipo, np.datetime64)) + (issubclass(tipo, np.datetime64) or + issubclass(tipo, np.timedelta64))) def is_datetime64_dtype(arr_or_dtype): diff --git a/pandas/tests/test_format.py b/pandas/tests/test_format.py index 30a35a5bea269..9a2e148257229 100644 --- a/pandas/tests/test_format.py +++ b/pandas/tests/test_format.py @@ -879,6 +879,11 @@ def test_float_trim_zeros(self): for line in repr(Series(vals)).split('\n'): self.assert_('+10' in line) + def test_timedelta64(self): + Series(np.array([1100, 20], dtype='timedelta64[s]')).to_string() + #check this works + #GH2146 + class TestEngFormatter(unittest.TestCase):