@@ -1022,20 +1022,13 @@ def interpolate(
1022
1022
of similar names. See Notes.
1023
1023
* 'from_derivatives': Refers to scipy.interpolate.BPoly.from_derivatives.
1024
1024
axis : int
1025
- Axis to interpolate along. For 1D NumpyExtensionArray , use 0.
1025
+ Axis to interpolate along. For 1-dimensional data , use 0.
1026
1026
index : Index
1027
1027
Index to use for interpolation.
1028
1028
limit : int or None
1029
1029
Maximum number of consecutive NaNs to fill. Must be greater than 0.
1030
1030
limit_direction : {'forward', 'backward', 'both'}
1031
1031
Consecutive NaNs will be filled in this direction.
1032
- * If 'method' is 'pad' or 'ffill', 'limit_direction' must be 'forward'.
1033
- * If 'method' is 'backfill' or 'bfill', 'limit_direction' must be
1034
- 'backward'.
1035
- Raises ValueError if limit_direction is 'forward' or 'both' and method
1036
- is 'backfill' or 'bfill'.
1037
- Raises ValueError if limit_direction is 'backward' or 'both' and method
1038
- is 'pad' or 'ffill'.
1039
1032
limit_area : {'inside', 'outside'} or None
1040
1033
If limit is specified, consecutive NaNs will be filled with this
1041
1034
restriction.
@@ -1049,8 +1042,8 @@ def interpolate(
1049
1042
1050
1043
Returns
1051
1044
-------
1052
- NumpyExtensionArray
1053
- A new NumpyExtensionArray with interpolated values.
1045
+ ExtensionArray
1046
+ An ExtensionArray with interpolated values.
1054
1047
1055
1048
See Also
1056
1049
--------
@@ -1063,11 +1056,12 @@ def interpolate(
1063
1056
- The 'krogh', 'piecewise_polynomial', 'spline', 'pchip' and 'akima'
1064
1057
methods are wrappers around the respective SciPy implementations of
1065
1058
similar names. These use the actual numerical values of the index.
1066
- - For 1D NumpyExtensionArray, use 0 for the `axis` parameter.
1067
1059
1068
1060
Examples
1069
1061
--------
1070
- >>> arr = pd.arrays.NumpyExtensionArray(np.array([0, np.nan, 2, np.nan, 4]))
1062
+ Interpolating values in a NumPy array:
1063
+
1064
+ >>> arr = pd.arrays.NumpyExtensionArray(np.array([0, 1, np.nan, 3]))
1071
1065
>>> arr.interpolate(
1072
1066
... method="linear",
1073
1067
... axis=0,
@@ -1078,8 +1072,24 @@ def interpolate(
1078
1072
... copy=True,
1079
1073
... )
1080
1074
<NumpyExtensionArray>
1081
- [0.0, 1.0, 2.0, 3.0, 4.0]
1082
- Length: 5, dtype: float64
1075
+ [0.0, 1.0, 2.0, 3.0]
1076
+ Length: 4, dtype: float64
1077
+
1078
+ Interpolating values in a FloatingArray:
1079
+
1080
+ >>> arr = pd.array([1.0, pd.NA, 3.0, 4.0, pd.NA, 6.0], dtype="Float64")
1081
+ >>> arr.interpolate(
1082
+ ... method="linear",
1083
+ ... axis=0,
1084
+ ... index=pd.Index(range(len(arr))),
1085
+ ... limit=None,
1086
+ ... limit_direction="both",
1087
+ ... limit_area=None,
1088
+ ... copy=True,
1089
+ ... )
1090
+ <FloatingArray>
1091
+ [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
1092
+ Length: 6, dtype: Float64
1083
1093
"""
1084
1094
# NB: we return type(self) even if copy=False
1085
1095
raise NotImplementedError (
0 commit comments