Skip to content

Commit 1cd8575

Browse files
committed
code review changes
1 parent 988bc09 commit 1cd8575

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

doc/source/whatsnew/v0.20.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Other enhancements
5353
- ``pd.cut`` and ``pd.qcut`` now support datetime64 and timedelta64 dtypes (issue:`14714`)
5454
- ``Series`` provides a ``to_excel`` method to output Excel files (:issue:`8825`)
5555
- The ``usecols`` argument in ``pd.read_csv`` now accepts a callable function as a value (:issue:`14154`)
56+
- The ``pd.Series.interpolate`` now supports timedelta as index type(:issue:`6424`)
5657

5758
.. _whatsnew_0200.api_breaking:
5859

pandas/core/missing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def _interp_limit(invalid, fw_limit, bw_limit):
188188
if method in ('values', 'index'):
189189
inds = np.asarray(xvalues)
190190
# hack for DatetimeIndex, #1646
191-
if (needs_i8_conversion(inds.dtype.type)):
191+
if needs_i8_conversion(inds.dtype.type):
192192
inds = inds.view(np.int64)
193193
if inds.dtype == np.object_:
194194
inds = lib.maybe_convert_objects(inds)

pandas/tests/series/test_missing.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -893,14 +893,21 @@ def test_spline_error(self):
893893

894894
def test_interp_timedelta64(self):
895895
# GH 6424
896-
tm._skip_if_no_scipy()
897896
df = Series([1, np.nan, 3],
898897
index=pd.to_timedelta([1, 2, 3]))
899898
result = df.interpolate(method='time')
900899
expected = Series([1., 2., 3.],
901900
index=pd.to_timedelta([1, 2, 3]))
902901
assert_series_equal(result, expected)
903902

903+
# test for non uniform spacing
904+
df = Series([1, np.nan, 3],
905+
index=pd.to_timedelta([1, 2, 4]))
906+
result = df.interpolate(method='time')
907+
expected = Series([1., 1.666667, 3.],
908+
index=pd.to_timedelta([1, 2, 4]))
909+
assert_series_equal(result, expected)
910+
904911

905912
if __name__ == '__main__':
906913
import nose

0 commit comments

Comments
 (0)