Skip to content

Commit 9f2d569

Browse files
committed
Update groupby corrwith's warning
1 parent 235c6fe commit 9f2d569

File tree

8 files changed

+26
-15
lines changed

8 files changed

+26
-15
lines changed

pandas/core/groupby/generic.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
Substitution,
3434
doc,
3535
)
36-
from pandas.util._exceptions import find_stack_level
36+
from pandas.util._exceptions import (
37+
Pandas40DeprecationWarning,
38+
find_stack_level,
39+
)
3740

3841
from pandas.core.dtypes.common import (
3942
ensure_int64,
@@ -2791,7 +2794,7 @@ def corrwith(
27912794
"""
27922795
warnings.warn(
27932796
"DataFrameGroupBy.corrwith is deprecated",
2794-
FutureWarning,
2797+
Pandas40DeprecationWarning,
27952798
stacklevel=find_stack_level(),
27962799
)
27972800
result = self._op_via_apply(

pandas/tests/groupby/test_all_methods.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
import pytest
1515

16+
from pandas.util._exceptions import Pandas40DeprecationWarning
17+
1618
import pandas as pd
1719
from pandas import DataFrame
1820
import pandas._testing as tm
@@ -26,7 +28,7 @@ def test_multiindex_group_all_columns_when_empty(groupby_func):
2628
method = getattr(gb, groupby_func)
2729
args = get_groupby_method_args(groupby_func, df)
2830
if groupby_func == "corrwith":
29-
warn = FutureWarning
31+
warn = Pandas40DeprecationWarning
3032
warn_msg = "DataFrameGroupBy.corrwith is deprecated"
3133
else:
3234
warn = None
@@ -72,7 +74,7 @@ def test_dup_labels_output_shape(groupby_func, idx):
7274

7375
args = get_groupby_method_args(groupby_func, df)
7476
if groupby_func == "corrwith":
75-
warn = FutureWarning
77+
warn = Pandas40DeprecationWarning
7678
warn_msg = "DataFrameGroupBy.corrwith is deprecated"
7779
else:
7880
warn = None

pandas/tests/groupby/test_apply.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import numpy as np
77
import pytest
88

9+
from pandas.util._exceptions import Pandas40DeprecationWarning
10+
911
import pandas as pd
1012
from pandas import (
1113
DataFrame,
@@ -1198,7 +1200,7 @@ def test_apply_is_unchanged_when_other_methods_are_called_first(reduction_func):
11981200
grp = df.groupby(by="a")
11991201
args = get_groupby_method_args(reduction_func, df)
12001202
if reduction_func == "corrwith":
1201-
warn = FutureWarning
1203+
warn = Pandas40DeprecationWarning
12021204
msg = "DataFrameGroupBy.corrwith is deprecated"
12031205
else:
12041206
warn = None

pandas/tests/groupby/test_categorical.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import numpy as np
44
import pytest
55

6+
from pandas.util._exceptions import Pandas40DeprecationWarning
7+
68
import pandas as pd
79
from pandas import (
810
Categorical,
@@ -1474,7 +1476,7 @@ def test_dataframe_groupby_on_2_categoricals_when_observed_is_true(reduction_fun
14741476

14751477
args = get_groupby_method_args(reduction_func, df)
14761478
if reduction_func == "corrwith":
1477-
warn = FutureWarning
1479+
warn = Pandas40DeprecationWarning
14781480
warn_msg = "DataFrameGroupBy.corrwith is deprecated"
14791481
else:
14801482
warn = None
@@ -1520,7 +1522,7 @@ def test_dataframe_groupby_on_2_categoricals_when_observed_is_false(
15201522
return
15211523

15221524
if reduction_func == "corrwith":
1523-
warn = FutureWarning
1525+
warn = Pandas40DeprecationWarning
15241526
warn_msg = "DataFrameGroupBy.corrwith is deprecated"
15251527
else:
15261528
warn = None
@@ -1919,7 +1921,7 @@ def test_category_order_reducer(
19191921
getattr(gb, reduction_func)(*args)
19201922
return
19211923
if reduction_func == "corrwith":
1922-
warn = FutureWarning
1924+
warn = Pandas40DeprecationWarning
19231925
warn_msg = "DataFrameGroupBy.corrwith is deprecated"
19241926
else:
19251927
warn = None

pandas/tests/groupby/test_groupby_dropna.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33

44
from pandas.compat.pyarrow import pa_version_under10p1
5+
from pandas.util._exceptions import Pandas40DeprecationWarning
56

67
from pandas.core.dtypes.missing import na_value_for_dtype
78

@@ -544,7 +545,7 @@ def test_categorical_reducers(reduction_func, observed, sort, as_index, index_ki
544545

545546
gb_filled = df_filled.groupby(keys, observed=observed, sort=sort, as_index=True)
546547
if reduction_func == "corrwith":
547-
warn = FutureWarning
548+
warn = Pandas40DeprecationWarning
548549
msg = "DataFrameGroupBy.corrwith is deprecated"
549550
else:
550551
warn = None
@@ -575,7 +576,7 @@ def test_categorical_reducers(reduction_func, observed, sort, as_index, index_ki
575576
expected = expected["size"].rename(None)
576577

577578
if reduction_func == "corrwith":
578-
warn = FutureWarning
579+
warn = Pandas40DeprecationWarning
579580
msg = "DataFrameGroupBy.corrwith is deprecated"
580581
else:
581582
warn = None

pandas/tests/groupby/test_numeric_only.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44

55
from pandas._libs import lib
6+
from pandas.util._exceptions import Pandas40DeprecationWarning
67

78
import pandas as pd
89
from pandas import (
@@ -257,7 +258,7 @@ def test_numeric_only(kernel, has_arg, numeric_only, keys):
257258
if has_arg and numeric_only is True:
258259
# Cases where b does not appear in the result
259260
if kernel == "corrwith":
260-
warn = FutureWarning
261+
warn = Pandas40DeprecationWarning
261262
msg = "DataFrameGroupBy.corrwith is deprecated"
262263
else:
263264
warn = None
@@ -304,7 +305,7 @@ def test_numeric_only(kernel, has_arg, numeric_only, keys):
304305
msg = "'>' not supported between instances of 'type' and 'type'"
305306
with pytest.raises(exception, match=msg):
306307
if kernel == "corrwith":
307-
warn = FutureWarning
308+
warn = Pandas40DeprecationWarning
308309
msg = "DataFrameGroupBy.corrwith is deprecated"
309310
else:
310311
warn = None

pandas/tests/groupby/transform/test_transform.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55

66
from pandas._libs import lib
7+
from pandas.util._exceptions import Pandas40DeprecationWarning
78

89
from pandas.core.dtypes.common import ensure_platform_int
910

@@ -1105,7 +1106,7 @@ def test_transform_agg_by_name(request, reduction_func, frame_or_series):
11051106

11061107
args = get_groupby_method_args(reduction_func, obj)
11071108
if func == "corrwith":
1108-
warn = FutureWarning
1109+
warn = Pandas40DeprecationWarning
11091110
msg = "DataFrameGroupBy.corrwith is deprecated"
11101111
else:
11111112
warn = None
@@ -1476,7 +1477,7 @@ def test_as_index_no_change(keys, df, groupby_func):
14761477
gb_as_index_true = df.groupby(keys, as_index=True)
14771478
gb_as_index_false = df.groupby(keys, as_index=False)
14781479
if groupby_func == "corrwith":
1479-
warn = FutureWarning
1480+
warn = Pandas40DeprecationWarning
14801481
msg = "DataFrameGroupBy.corrwith is deprecated"
14811482
else:
14821483
warn = None

pandas/tests/io/json/test_pandas.py

-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ def test_frame_non_unique_columns(self, orient, data, request):
151151
if df.iloc[:, 0].dtype == "datetime64[s]":
152152
expected_warning = Pandas40DeprecationWarning
153153

154-
155154
with tm.assert_produces_warning(expected_warning, match=msg):
156155
result = read_json(
157156
StringIO(df.to_json(orient=orient)), orient=orient, convert_dates=["x"]

0 commit comments

Comments
 (0)