Skip to content

Commit 9b0eaa4

Browse files
changhiskhanwesm
authored andcommitted
BUG: exclude timedelta64 from integer dtypes #2146
1 parent 8bdaf61 commit 9b0eaa4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pandas/core/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def _isnull_ndarraylike(obj):
9090
elif values.dtype == np.dtype('M8[ns]'):
9191
# this is the NaT pattern
9292
result = values.view('i8') == lib.iNaT
93+
elif issubclass(values.dtype.type, np.timedelta64):
94+
result = -np.isfinite(values.view('i8'))
9395
else:
9496
result = -np.isfinite(obj)
9597
return result
@@ -800,7 +802,8 @@ def is_integer_dtype(arr_or_dtype):
800802
else:
801803
tipo = arr_or_dtype.dtype.type
802804
return (issubclass(tipo, np.integer) and not
803-
issubclass(tipo, np.datetime64))
805+
(issubclass(tipo, np.datetime64) or
806+
issubclass(tipo, np.timedelta64)))
804807

805808

806809
def is_datetime64_dtype(arr_or_dtype):

pandas/tests/test_format.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,11 @@ def test_float_trim_zeros(self):
879879
for line in repr(Series(vals)).split('\n'):
880880
self.assert_('+10' in line)
881881

882+
def test_timedelta64(self):
883+
Series(np.array([1100, 20], dtype='timedelta64[s]')).to_string()
884+
#check this works
885+
#GH2146
886+
882887

883888
class TestEngFormatter(unittest.TestCase):
884889

0 commit comments

Comments
 (0)