@@ -7668,8 +7668,12 @@ def interpolate(
7668
7668
* 'linear': Ignore the index and treat the values as equally
7669
7669
spaced. This is the only method supported on MultiIndexes.
7670
7670
* 'time': Works on daily and higher resolution data to interpolate
7671
- given length of interval.
7672
- * 'index', 'values': use the actual numerical values of the index.
7671
+ given length of interval. This interpolates values based on
7672
+ time interval between observations.
7673
+ * 'index': The interpolation uses the actual numerical values
7674
+ of the df's index to linearly calculate missing value.
7675
+ * 'value': Interpolation based on the actual numerical values
7676
+ in the DataFrame, treating them as equally spaced along the index.
7673
7677
* 'nearest', 'zero', 'slinear', 'quadratic', 'cubic',
7674
7678
'barycentric', 'polynomial': Passed to
7675
7679
`scipy.interpolate.interp1d`, whereas 'spline' is passed to
@@ -7798,6 +7802,26 @@ def interpolate(
7798
7802
2 2.0 3.0 -3.0 9.0
7799
7803
3 2.0 4.0 -4.0 16.0
7800
7804
7805
+ Using linear and index method for linear interpolation.
7806
+ >>> data = {"val": [1, np.nan, 3]}
7807
+ >>> df = pd.DataFrame(
7808
+ ... data, index=[0, 1, 6]
7809
+ ... ) # a non-sequential index to demonstrate the difference
7810
+ >>> df
7811
+ val
7812
+ 0 1.0
7813
+ 1 NaN
7814
+ 6 3.0
7815
+ >>> df.interpolate(method="linear")
7816
+ val
7817
+ 0 1.0
7818
+ 1 2.0
7819
+ 6 3.0
7820
+ >>> df.interpolate(method="index")
7821
+ val
7822
+ 0 1.000000
7823
+ 1 1.333333
7824
+ 6 3.000000
7801
7825
Using polynomial interpolation.
7802
7826
7803
7827
>>> df["d"].interpolate(method="polynomial", order=2)
0 commit comments