@@ -7668,8 +7668,12 @@ def interpolate(
76687668 * 'linear': Ignore the index and treat the values as equally
76697669 spaced. This is the only method supported on MultiIndexes.
76707670 * '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.
76737677 * 'nearest', 'zero', 'slinear', 'quadratic', 'cubic',
76747678 'barycentric', 'polynomial': Passed to
76757679 `scipy.interpolate.interp1d`, whereas 'spline' is passed to
@@ -7798,6 +7802,26 @@ def interpolate(
77987802 2 2.0 3.0 -3.0 9.0
77997803 3 2.0 4.0 -4.0 16.0
78007804
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
78017825 Using polynomial interpolation.
78027826
78037827 >>> df["d"].interpolate(method="polynomial", order=2)
0 commit comments