Calling the pd.Series interpolate with method='time' returns inconsistent results when the first or the last value is NaN.
When the first value is NaN, interpolation is not performed on the first value. This is, for me, the expected behaviour since interpolation is not possible.
pd.Series(index=[datetime(2017,1,1), datetime(2017,1,2), datetime(2017,1,7)], data=[float('nan'), float('nan'), 3]).interpolate(method='time')
2017-01-01 NaN 2017-01-02 NaN 2017-01-07 3.0 dtype: float64
When the last value is a NaN, 'interpolation' is performed (like a forward-fill). I was expecting to keep the NaN values
pd.Series(index=[datetime(2017,1,1), datetime(2017,1,2), datetime(2017,1,7)], data=[1, float('nan'), float('nan')]).interpolate(method='time')
2017-01-01 1.0 2017-01-02 1.0 2017-01-07 1.0 dtype: float64
Comment From: jorisvandenbossche
This does not seem to be specific to 'time' interpolation, as for more simple cases you see the same behaviour:
In [58]: pd.Series([1, 2, np.nan], index=[1,2,4]).interpolate()
Out[58]:
1 1.0
2 2.0
4 2.0
dtype: float64
In [59]: pd.Series([1, 2, np.nan], index=[1,2,4]).interpolate(method='index')
Out[59]:
1 1.0
2 2.0
4 2.0
dtype: float64
To me that feels like a bug (or at least not a behaviour that is mentioned in the docs), but not too familiar with the interpolate code.
Comment From: jorisvandenbossche
OK, this is a duplicate of https://github.com/pandas-dev/pandas/issues/8000. Always welcome to look into this and submit a PR!