Skip to content

Commit b0e0a06

Browse files
committed
Merge branch 'rework-fix-9011' of https://github.com/ahjulstad/pandas into ahjulstad-rework-fix-9011
2 parents 4f526fe + e938670 commit b0e0a06

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pandas/tseries/tests/test_timedeltas.py

+7
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,13 @@ def test_constructor(self):
852852
pd.offsets.Second(3)])
853853
tm.assert_index_equal(result,expected)
854854

855+
expected = TimedeltaIndex(['0 days 00:00:00', '0 days 00:00:01', '0 days 00:00:02'])
856+
tm.assert_index_equal(TimedeltaIndex(range(3), unit='s'), expected)
857+
expected = TimedeltaIndex(['0 days 00:00:00', '0 days 00:00:05', '0 days 00:00:09'])
858+
tm.assert_index_equal(TimedeltaIndex([0, 5, 9], unit='s'), expected)
859+
expected = TimedeltaIndex(['0 days 00:00:00.400', '0 days 00:00:00.450', '0 days 00:00:01.200'])
860+
tm.assert_index_equal(TimedeltaIndex([400, 450, 1200], unit='ms'), expected)
861+
855862
def test_constructor_coverage(self):
856863
rng = timedelta_range('1 days', periods=10.5)
857864
exp = timedelta_range('1 days', periods=10)

pandas/tseries/timedeltas.py

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def _convert_listlike(arg, box, unit):
5252
value = np.array([ _get_string_converter(r, unit=unit)() for r in arg ],dtype='m8[ns]')
5353
except:
5454
value = np.array([ _coerce_scalar_to_timedelta_type(r, unit=unit, coerce=coerce) for r in arg ])
55+
value = value.astype('timedelta64[ns]', copy=False)
5556

5657
if box:
5758
from pandas import TimedeltaIndex

0 commit comments

Comments
 (0)