@@ -999,16 +999,74 @@ def interpolate(
999999 ** kwargs ,
10001000 ) -> Self :
10011001 """
1002- See DataFrame.interpolate.__doc__.
1002+ Fill NaN values using an interpolation method.
1003+
1004+ Parameters
1005+ ----------
1006+ method : str, default 'linear'
1007+ Interpolation technique to use. One of:
1008+ * 'linear': Ignore the index and treat the values as equally spaced.
1009+ This is the only method supported on MultiIndexes.
1010+ * 'time': Works on daily and higher resolution data to interpolate
1011+ given length of interval.
1012+ * 'index', 'values': use the actual numerical values of the index.
1013+ * 'pad': Fill in NaNs using existing values.
1014+ * 'nearest', 'zero', 'slinear', 'quadratic', 'cubic', 'barycentric',
1015+ 'polynomial': Passed to scipy.interpolate.interp1d, whereas 'spline'
1016+ is passed to scipy.interpolate.UnivariateSpline. These methods use
1017+ the numerical values of the index.
1018+ Both 'polynomial' and 'spline' require that you also specify an
1019+ order (int), e.g. arr.interpolate(method='polynomial', order=5).
1020+ * 'krogh', 'piecewise_polynomial', 'spline', 'pchip', 'akima',
1021+ 'cubicspline': Wrappers around the SciPy interpolation methods
1022+ of similar names. See Notes.
1023+ * 'from_derivatives': Refers to scipy.interpolate.BPoly.from_derivatives.
1024+ axis : int
1025+ Axis to interpolate along. For 1-dimensional data, use 0.
1026+ index : Index
1027+ Index to use for interpolation.
1028+ limit : int or None
1029+ Maximum number of consecutive NaNs to fill. Must be greater than 0.
1030+ limit_direction : {'forward', 'backward', 'both'}
1031+ Consecutive NaNs will be filled in this direction.
1032+ limit_area : {'inside', 'outside'} or None
1033+ If limit is specified, consecutive NaNs will be filled with this
1034+ restriction.
1035+ * None: No fill restriction.
1036+ * 'inside': Only fill NaNs surrounded by valid values (interpolate).
1037+ * 'outside': Only fill NaNs outside valid values (extrapolate).
1038+ copy : bool
1039+ If True, a copy of the object is returned with interpolated values.
1040+ **kwargs : optional
1041+ Keyword arguments to pass on to the interpolating function.
1042+
1043+ Returns
1044+ -------
1045+ ExtensionArray
1046+ An ExtensionArray with interpolated values.
1047+
1048+ See Also
1049+ --------
1050+ Series.interpolate : Interpolate values in a Series.
1051+ DataFrame.interpolate : Interpolate values in a DataFrame.
1052+
1053+ Notes
1054+ -----
1055+ - All parameters must be specified as keyword arguments.
1056+ - The 'krogh', 'piecewise_polynomial', 'spline', 'pchip' and 'akima'
1057+ methods are wrappers around the respective SciPy implementations of
1058+ similar names. These use the actual numerical values of the index.
10031059
10041060 Examples
10051061 --------
1062+ Interpolating values in a NumPy array:
1063+
10061064 >>> arr = pd.arrays.NumpyExtensionArray(np.array([0, 1, np.nan, 3]))
10071065 >>> arr.interpolate(
10081066 ... method="linear",
10091067 ... limit=3,
10101068 ... limit_direction="forward",
1011- ... index=pd.Index([1, 2, 3, 4] ),
1069+ ... index=pd.Index(range(len(arr)) ),
10121070 ... fill_value=1,
10131071 ... copy=False,
10141072 ... axis=0,
@@ -1017,6 +1075,22 @@ def interpolate(
10171075 <NumpyExtensionArray>
10181076 [0.0, 1.0, 2.0, 3.0]
10191077 Length: 4, dtype: float64
1078+
1079+ Interpolating values in a FloatingArray:
1080+
1081+ >>> arr = pd.array([1.0, pd.NA, 3.0, 4.0, pd.NA, 6.0], dtype="Float64")
1082+ >>> arr.interpolate(
1083+ ... method="linear",
1084+ ... axis=0,
1085+ ... index=pd.Index(range(len(arr))),
1086+ ... limit=None,
1087+ ... limit_direction="both",
1088+ ... limit_area=None,
1089+ ... copy=True,
1090+ ... )
1091+ <FloatingArray>
1092+ [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
1093+ Length: 6, dtype: Float64
10201094 """
10211095 # NB: we return type(self) even if copy=False
10221096 raise NotImplementedError (
0 commit comments