Skip to content

Commit fbec52b

Browse files
authored
interpolate method (#761)
1 parent 794948a commit fbec52b

File tree

6 files changed

+31
-50
lines changed

6 files changed

+31
-50
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
hooks:
1212
- id: isort
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.0.278
14+
rev: v0.0.282
1515
hooks:
1616
- id: ruff
1717
args: [

pandas-stubs/_typing.pyi

+20
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,26 @@ StataDateFormat: TypeAlias = Literal[
664664
]
665665

666666
FillnaOptions: TypeAlias = Literal["backfill", "bfill", "ffill", "pad"]
667+
InterpolateOptions: TypeAlias = Literal[
668+
"linear",
669+
"time",
670+
"index",
671+
"pad",
672+
"nearest",
673+
"zero",
674+
"slinear",
675+
"quadratic",
676+
"cubic",
677+
"barycentric",
678+
"polynomial",
679+
"krogh",
680+
"piecewise_polynomial",
681+
"spline",
682+
"pchip",
683+
"akima",
684+
"cubicspline",
685+
"from_derivatives",
686+
]
667687
ReplaceMethod: TypeAlias = Literal["pad", "ffill", "bfill"]
668688
SortKind: TypeAlias = Literal["quicksort", "mergesort", "heapsort", "stable"]
669689
NaPosition: TypeAlias = Literal["first", "last"]

pandas-stubs/core/frame.pyi

+4-3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ from pandas._typing import (
8686
IndexingInt,
8787
IndexLabel,
8888
IndexType,
89+
InterpolateOptions,
8990
IntervalClosedType,
9091
IntervalT,
9192
JoinHow,
@@ -1704,7 +1705,7 @@ class DataFrame(NDFrame, OpsMixin):
17041705
@overload
17051706
def interpolate(
17061707
self,
1707-
method: _str = ...,
1708+
method: InterpolateOptions = ...,
17081709
*,
17091710
axis: Axis = ...,
17101711
limit: int | None = ...,
@@ -1717,7 +1718,7 @@ class DataFrame(NDFrame, OpsMixin):
17171718
@overload
17181719
def interpolate(
17191720
self,
1720-
method: _str = ...,
1721+
method: InterpolateOptions = ...,
17211722
*,
17221723
axis: Axis = ...,
17231724
limit: int | None = ...,
@@ -1730,7 +1731,7 @@ class DataFrame(NDFrame, OpsMixin):
17301731
@overload
17311732
def interpolate(
17321733
self,
1733-
method: _str = ...,
1734+
method: InterpolateOptions = ...,
17341735
*,
17351736
axis: Axis = ...,
17361737
limit: int | None = ...,

pandas-stubs/core/resample.pyi

+3-24
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ from typing_extensions import TypeAlias
2222

2323
from pandas._typing import (
2424
Axis,
25+
InterpolateOptions,
2526
NDFrameT,
2627
Scalar,
2728
npt,
@@ -50,28 +51,6 @@ _SeriesGroupByFuncArgs: TypeAlias = (
5051
_SeriesGroupByFuncTypes | Mapping[Hashable, _SeriesGroupByFunc | str]
5152
)
5253

53-
_Interpolation: TypeAlias = Literal[
54-
"linear",
55-
"time",
56-
"index",
57-
"pad",
58-
"nearest",
59-
"zero",
60-
"slinear",
61-
"quadratic",
62-
"cubic",
63-
"spline",
64-
"barycentric",
65-
"polynomial",
66-
"krogh",
67-
"piecewise_polynomial",
68-
"spline",
69-
"pchip",
70-
"akima",
71-
"cubicspline",
72-
"from_derivatives",
73-
]
74-
7554
class Resampler(BaseGroupBy, Generic[NDFrameT]):
7655
def __getattr__(self, attr: str) -> SeriesGroupBy: ...
7756
def __iter__(self) -> Generator[tuple[Hashable, NDFrameT], None, None]: ...
@@ -147,7 +126,7 @@ class Resampler(BaseGroupBy, Generic[NDFrameT]):
147126
@overload
148127
def interpolate(
149128
self,
150-
method: _Interpolation = ...,
129+
method: InterpolateOptions = ...,
151130
*,
152131
axis: Axis = ...,
153132
limit: int | None = ...,
@@ -160,7 +139,7 @@ class Resampler(BaseGroupBy, Generic[NDFrameT]):
160139
@overload
161140
def interpolate(
162141
self,
163-
method: _Interpolation = ...,
142+
method: InterpolateOptions = ...,
164143
*,
165144
axis: Axis = ...,
166145
limit: int | None = ...,

pandas-stubs/core/series.pyi

+2-21
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ from pandas._typing import (
118118
IgnoreRaise,
119119
IndexingInt,
120120
IntDtypeArg,
121+
InterpolateOptions,
121122
IntervalClosedType,
122123
IntervalT,
123124
JoinHow,
@@ -1273,27 +1274,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
12731274
) -> Series[S1] | None: ...
12741275
def interpolate(
12751276
self,
1276-
method: _str
1277-
| Literal[
1278-
"linear",
1279-
"time",
1280-
"index",
1281-
"values",
1282-
"pad",
1283-
"nearest",
1284-
"slinear",
1285-
"quadratic",
1286-
"cubic",
1287-
"spline",
1288-
"barycentric",
1289-
"polynomial",
1290-
"krogh",
1291-
"pecewise_polynomial",
1292-
"spline",
1293-
"pchip",
1294-
"akima",
1295-
"from_derivatives",
1296-
] = ...,
1277+
method: InterpolateOptions = ...,
12971278
*,
12981279
axis: AxisIndex | None = ...,
12991280
limit: int | None = ...,

tests/test_scalars.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@ def test_period_add_subtract() -> None:
17451745
as_dt_td = dt.timedelta(days=1)
17461746
as_np_td = np.timedelta64(1, "D")
17471747
as_np_i64 = np.int64(1)
1748-
as_int = int(1)
1748+
as_int: int = 1
17491749
as_period_index = pd.period_range("2012-1-1", periods=10, freq="D")
17501750
check(assert_type(as_period_index, pd.PeriodIndex), pd.PeriodIndex)
17511751
as_period = pd.Period("2012-1-1", freq="D")

0 commit comments

Comments
 (0)