Skip to content

Commit

Permalink
FIX-#6684: Adapt to pandas 2.1.2 (#6685)
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev committed Nov 16, 2023
1 parent f0c1c03 commit 68b6357
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
12 changes: 6 additions & 6 deletions modin/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2188,13 +2188,13 @@ def pct_change(
"""
Percentage change between the current and a prior element.
"""
if fill_method is not lib.no_default or limit is not lib.no_default:
if fill_method not in (lib.no_default, None) or limit is not lib.no_default:
warnings.warn(
"The 'fill_method' and 'limit' keywords in "
+ f"{type(self).__name__}.pct_change are deprecated and will be "
+ "removed in a future version. Call "
+ f"{'bfill' if fill_method in ('backfill', 'bfill') else 'ffill'} "
+ "before calling pct_change instead.",
"The 'fill_method' keyword being not None and the 'limit' keyword in "
+ f"{type(self).__name__}.pct_change are deprecated and will be removed "
+ "in a future version. Either fill in any non-leading NA values prior "
+ "to calling pct_change or specify 'fill_method=None' to not fill NA "
+ "values.",
FutureWarning,
)
if fill_method is lib.no_default:
Expand Down
12 changes: 6 additions & 6 deletions modin/pandas/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,13 @@ def pct_change(
):
from .dataframe import DataFrame

if fill_method is not lib.no_default or limit is not lib.no_default:
if fill_method not in (lib.no_default, None) or limit is not lib.no_default:
warnings.warn(
"The 'fill_method' and 'limit' keywords in "
+ f"{type(self).__name__}.pct_change are deprecated and will be "
+ "removed in a future version. Call "
+ f"{'bfill' if fill_method in ('backfill', 'bfill') else 'ffill'} "
+ "before calling pct_change instead.",
"The 'fill_method' keyword being not None and the 'limit' keyword in "
+ f"{type(self).__name__}.pct_change are deprecated and will be removed "
+ "in a future version. Either fill in any non-leading NA values prior "
+ "to calling pct_change or specify 'fill_method=None' to not fill NA "
+ "values.",
FutureWarning,
)
if fill_method is lib.no_default:
Expand Down
12 changes: 9 additions & 3 deletions modin/pandas/test/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"ignore:DataFrameGroupBy.pct_change with axis=1 is deprecated:FutureWarning"
),
pytest.mark.filterwarnings(
"ignore:The 'fill_method' and 'limit' keywords in (DataFrame|DataFrameGroupBy).pct_change are deprecated:FutureWarning"
"ignore:The 'fill_method' keyword being not None and the 'limit' keyword "
+ "in (DataFrame|DataFrameGroupBy).pct_change are deprecated:FutureWarning"
),
pytest.mark.filterwarnings(
"ignore:DataFrameGroupBy.shift with axis=1 is deprecated:FutureWarning"
Expand Down Expand Up @@ -3061,14 +3062,19 @@ def test_groupby_pct_change_parameters_warning():
modin_groupby = modin_df.groupby(by="col1")
pandas_groupby = pandas_df.groupby(by="col1")

match_string = (
"The 'fill_method' keyword being not None and the 'limit' keyword "
+ "in (DataFrame|DataFrameGroupBy).pct_change are deprecated"
)

with pytest.warns(
FutureWarning,
match="The 'fill_method' and 'limit' keywords in (DataFrame|DataFrameGroupBy).pct_change are deprecated",
match=match_string,
):
modin_groupby.pct_change(fill_method="bfill", limit=1)
with pytest.warns(
FutureWarning,
match="The 'fill_method' and 'limit' keywords in (DataFrame|DataFrameGroupBy).pct_change are deprecated",
match=match_string,
):
pandas_groupby.pct_change(fill_method="bfill", limit=1)

Expand Down

0 comments on commit 68b6357

Please sign in to comment.