@@ -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,23 +1056,41 @@ 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]))
1065
+ >>> arr.interpolate(
1066
+ ... method="linear",
1067
+ ... limit=3,
1068
+ ... limit_direction="forward",
1069
+ ... index=pd.Index(range(len(arr))),
1070
+ ... fill_value=1,
1071
+ ... copy=False,
1072
+ ... axis=0,
1073
+ ... limit_area="inside",
1074
+ ... )
1075
+ <NumpyExtensionArray>
1076
+ [0.0, 1.0, 2.0, 3.0]
1077
+ 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")
1071
1082
>>> arr.interpolate(
1072
1083
... method="linear",
1073
1084
... axis=0,
1074
1085
... index=pd.Index(range(len(arr))),
1075
1086
... limit=None,
1076
- ... limit_direction="forward ",
1087
+ ... limit_direction="both ",
1077
1088
... limit_area=None,
1078
1089
... copy=True,
1079
1090
... )
1080
- <NumpyExtensionArray >
1081
- [0 .0, 1 .0, 2 .0, 3 .0, 4 .0]
1082
- Length: 5 , dtype: float64
1091
+ <FloatingArray >
1092
+ [1.0, 2 .0, 3 .0, 4 .0, 5 .0, 6 .0]
1093
+ Length: 6 , dtype: Float64
1083
1094
"""
1084
1095
# NB: we return type(self) even if copy=False
1085
1096
raise NotImplementedError (
0 commit comments