Skip to content

Commit

Permalink
interpolate method
Browse files Browse the repository at this point in the history
  • Loading branch information
twoertwein committed Aug 3, 2023
1 parent 8957328 commit 4929ecb
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.278
rev: v0.0.282
hooks:
- id: ruff
args: [
Expand Down
20 changes: 20 additions & 0 deletions pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,26 @@ StataDateFormat: TypeAlias = Literal[
]

FillnaOptions: TypeAlias = Literal["backfill", "bfill", "ffill", "pad"]
InterpolateOptions: TypeAlias = Literal[
"linear",
"time",
"index",
"pad",
"nearest",
"zero",
"slinear",
"quadratic",
"cubic",
"barycentric",
"polynomial",
"krogh",
"piecewise_polynomial",
"spline",
"pchip",
"akima",
"cubicspline",
"from_derivatives",
]
ReplaceMethod: TypeAlias = Literal["pad", "ffill", "bfill"]
SortKind: TypeAlias = Literal["quicksort", "mergesort", "heapsort", "stable"]
NaPosition: TypeAlias = Literal["first", "last"]
Expand Down
7 changes: 4 additions & 3 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ from pandas._typing import (
IndexingInt,
IndexLabel,
IndexType,
InterpolateOptions,
IntervalClosedType,
IntervalT,
JoinHow,
Expand Down Expand Up @@ -1704,7 +1705,7 @@ class DataFrame(NDFrame, OpsMixin):
@overload
def interpolate(
self,
method: _str = ...,
method: InterpolateOptions = ...,
*,
axis: Axis = ...,
limit: int | None = ...,
Expand All @@ -1717,7 +1718,7 @@ class DataFrame(NDFrame, OpsMixin):
@overload
def interpolate(
self,
method: _str = ...,
method: InterpolateOptions = ...,
*,
axis: Axis = ...,
limit: int | None = ...,
Expand All @@ -1730,7 +1731,7 @@ class DataFrame(NDFrame, OpsMixin):
@overload
def interpolate(
self,
method: _str = ...,
method: InterpolateOptions = ...,
*,
axis: Axis = ...,
limit: int | None = ...,
Expand Down
27 changes: 3 additions & 24 deletions pandas-stubs/core/resample.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ from typing_extensions import TypeAlias

from pandas._typing import (
Axis,
InterpolateOptions,
NDFrameT,
Scalar,
npt,
Expand Down Expand Up @@ -50,28 +51,6 @@ _SeriesGroupByFuncArgs: TypeAlias = (
_SeriesGroupByFuncTypes | Mapping[Hashable, _SeriesGroupByFunc | str]
)

_Interpolation: TypeAlias = Literal[
"linear",
"time",
"index",
"pad",
"nearest",
"zero",
"slinear",
"quadratic",
"cubic",
"spline",
"barycentric",
"polynomial",
"krogh",
"piecewise_polynomial",
"spline",
"pchip",
"akima",
"cubicspline",
"from_derivatives",
]

class Resampler(BaseGroupBy, Generic[NDFrameT]):
def __getattr__(self, attr: str) -> SeriesGroupBy: ...
def __iter__(self) -> Generator[tuple[Hashable, NDFrameT], None, None]: ...
Expand Down Expand Up @@ -147,7 +126,7 @@ class Resampler(BaseGroupBy, Generic[NDFrameT]):
@overload
def interpolate(
self,
method: _Interpolation = ...,
method: InterpolateOptions = ...,
*,
axis: Axis = ...,
limit: int | None = ...,
Expand All @@ -160,7 +139,7 @@ class Resampler(BaseGroupBy, Generic[NDFrameT]):
@overload
def interpolate(
self,
method: _Interpolation = ...,
method: InterpolateOptions = ...,
*,
axis: Axis = ...,
limit: int | None = ...,
Expand Down
23 changes: 2 additions & 21 deletions pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ from pandas._typing import (
IgnoreRaise,
IndexingInt,
IntDtypeArg,
InterpolateOptions,
IntervalClosedType,
IntervalT,
JoinHow,
Expand Down Expand Up @@ -1273,27 +1274,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
) -> Series[S1] | None: ...
def interpolate(
self,
method: _str
| Literal[
"linear",
"time",
"index",
"values",
"pad",
"nearest",
"slinear",
"quadratic",
"cubic",
"spline",
"barycentric",
"polynomial",
"krogh",
"pecewise_polynomial",
"spline",
"pchip",
"akima",
"from_derivatives",
] = ...,
method: InterpolateOptions = ...,
*,
axis: AxisIndex | None = ...,
limit: int | None = ...,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_scalars.py
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ def test_period_add_subtract() -> None:
as_dt_td = dt.timedelta(days=1)
as_np_td = np.timedelta64(1, "D")
as_np_i64 = np.int64(1)
as_int = int(1)
as_int: int = 1
as_period_index = pd.period_range("2012-1-1", periods=10, freq="D")
check(assert_type(as_period_index, pd.PeriodIndex), pd.PeriodIndex)
as_period = pd.Period("2012-1-1", freq="D")
Expand Down

0 comments on commit 4929ecb

Please sign in to comment.