From 8186dfdb162ad74153c66cc46b49e9629419ba5e Mon Sep 17 00:00:00 2001 From: pierre-ubuntu Date: Sat, 9 Nov 2024 06:48:02 -0800 Subject: [PATCH 1/4] add limit_area parameter in ffill and bfill methods --- pandas-stubs/core/frame.pyi | 4 ++++ tests/test_frame.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/pandas-stubs/core/frame.pyi b/pandas-stubs/core/frame.pyi index 80a1e8a6..9ba351f6 100644 --- a/pandas-stubs/core/frame.pyi +++ b/pandas-stubs/core/frame.pyi @@ -1656,6 +1656,7 @@ class DataFrame(NDFrame, OpsMixin): axis: Axis | None = ..., inplace: Literal[True], limit: int | None = ..., + limit_area: Literal["inside", "outside"] | None = ..., downcast: dict | None = ..., ) -> None: ... @overload @@ -1665,6 +1666,7 @@ class DataFrame(NDFrame, OpsMixin): axis: Axis | None = ..., inplace: Literal[False] = ..., limit: int | None = ..., + limit_area: Literal["inside", "outside"] | None = ..., downcast: dict | None = ..., ) -> DataFrame: ... def clip( @@ -1736,6 +1738,7 @@ class DataFrame(NDFrame, OpsMixin): axis: Axis | None = ..., inplace: Literal[True], limit: int | None = ..., + limit_area: Literal["inside", "outside"] | None = ..., downcast: dict | None = ..., ) -> None: ... @overload @@ -1745,6 +1748,7 @@ class DataFrame(NDFrame, OpsMixin): axis: Axis | None = ..., inplace: Literal[False] = ..., limit: int | None = ..., + limit_area: Literal["inside", "outside"] | None = ..., downcast: dict | None = ..., ) -> DataFrame: ... def filter( diff --git a/tests/test_frame.py b/tests/test_frame.py index bee41a20..bc148b4b 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -2328,7 +2328,12 @@ def test_types_ffill() -> None: df = pd.DataFrame([[1, 2, 3]]) check(assert_type(df.ffill(), pd.DataFrame), pd.DataFrame) check(assert_type(df.ffill(inplace=False), pd.DataFrame), pd.DataFrame) + check( + assert_type(df.ffill(inplace=False, limit_area="inside"), pd.DataFrame), + pd.DataFrame, + ) assert assert_type(df.ffill(inplace=True), None) is None + assert assert_type(df.ffill(inplace=True, limit_area="outside"), None) is None def test_types_bfill() -> None: @@ -2336,7 +2341,12 @@ def test_types_bfill() -> None: df = pd.DataFrame([[1, 2, 3]]) check(assert_type(df.bfill(), pd.DataFrame), pd.DataFrame) check(assert_type(df.bfill(inplace=False), pd.DataFrame), pd.DataFrame) + check( + assert_type(df.bfill(inplace=False, limit_area="inside"), pd.DataFrame), + pd.DataFrame, + ) assert assert_type(df.bfill(inplace=True), None) is None + assert assert_type(df.bfill(inplace=True, limit_area="outside"), None) is None def test_types_replace() -> None: From 1897e2fb3df38966052a6ba7a05fee6cb7305e44 Mon Sep 17 00:00:00 2001 From: pierre-ubuntu Date: Mon, 11 Nov 2024 07:07:22 -0800 Subject: [PATCH 2/4] add limit_area parameter to Series bfill and ffill methods --- tests/test_series.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_series.py b/tests/test_series.py index 8a7300be..1ea1b717 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -1160,7 +1160,13 @@ def test_types_bfill() -> None: s1 = pd.Series([1, 2, 3]) check(assert_type(s1.bfill(), "pd.Series[int]"), pd.Series, np.integer) check(assert_type(s1.bfill(inplace=False), "pd.Series[int]"), pd.Series, np.integer) + check( + assert_type(s1.bfill(inplace=False, limit_area="inside"), "pd.Series[int]"), + pd.Series, + np.integer, + ) assert assert_type(s1.bfill(inplace=True), None) is None + assert assert_type(s1.bfill(inplace=True, limit_area="outside"), None) is None def test_types_ewm() -> None: @@ -1205,7 +1211,13 @@ def test_types_ffill() -> None: s1 = pd.Series([1, 2, 3]) check(assert_type(s1.ffill(), "pd.Series[int]"), pd.Series, np.integer) check(assert_type(s1.ffill(inplace=False), "pd.Series[int]"), pd.Series, np.integer) + check( + assert_type(s1.ffill(inplace=False, limit_area="inside"), "pd.Series[int]"), + pd.Series, + np.integer, + ) assert assert_type(s1.ffill(inplace=True), None) is None + assert assert_type(s1.ffill(inplace=True, limit_area="outside"), None) is None def test_types_as_type() -> None: From e7457771542974802887302aa6d7a2ef83f32d1a Mon Sep 17 00:00:00 2001 From: pierre-ubuntu Date: Mon, 11 Nov 2024 07:08:34 -0800 Subject: [PATCH 3/4] add limit_area parameter to Series bfill and ffill methods --- pandas-stubs/core/series.pyi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index 080c6a82..9acf2962 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -1300,6 +1300,7 @@ class Series(IndexOpsMixin[S1], NDFrame): axis: AxisIndex | None = ..., inplace: Literal[True], limit: int | None = ..., + limit_area: Literal["inside", "outside"] | None = ..., downcast: dict | None = ..., ) -> None: ... @overload @@ -1309,6 +1310,7 @@ class Series(IndexOpsMixin[S1], NDFrame): axis: AxisIndex | None = ..., inplace: Literal[False] = ..., limit: int | None = ..., + limit_area: Literal["inside", "outside"] | None = ..., downcast: dict | None = ..., ) -> Series[S1]: ... @overload @@ -1318,6 +1320,7 @@ class Series(IndexOpsMixin[S1], NDFrame): axis: AxisIndex | None = ..., inplace: Literal[True], limit: int | None = ..., + limit_area: Literal["inside", "outside"] | None = ..., downcast: dict | None = ..., ) -> None: ... @overload @@ -1327,6 +1330,7 @@ class Series(IndexOpsMixin[S1], NDFrame): axis: AxisIndex | None = ..., inplace: Literal[False] = ..., limit: int | None = ..., + limit_area: Literal["inside", "outside"] | None = ..., downcast: dict | None = ..., ) -> Series[S1]: ... @overload @@ -1337,6 +1341,7 @@ class Series(IndexOpsMixin[S1], NDFrame): axis: AxisIndex = ..., inplace: _bool = ..., limit: int | None = ..., + limit_area: Literal["inside", "outside"] | None = ..., downcast: dict | None = ..., ) -> Series[S1] | None: ... def interpolate( From f7d565e18b6081d09783c8b6ea271150f957665d Mon Sep 17 00:00:00 2001 From: pierre-ubuntu Date: Mon, 11 Nov 2024 08:20:46 -0800 Subject: [PATCH 4/4] remove irrelevant definition of series bfill --- pandas-stubs/core/series.pyi | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index 9acf2962..ce27d44e 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -1333,17 +1333,6 @@ class Series(IndexOpsMixin[S1], NDFrame): limit_area: Literal["inside", "outside"] | None = ..., downcast: dict | None = ..., ) -> Series[S1]: ... - @overload - def bfill( - self, - *, - value: S1 | dict | Series[S1] | DataFrame, - axis: AxisIndex = ..., - inplace: _bool = ..., - limit: int | None = ..., - limit_area: Literal["inside", "outside"] | None = ..., - downcast: dict | None = ..., - ) -> Series[S1] | None: ... def interpolate( self, method: InterpolateOptions = ...,