Skip to content

Commit e750d50

Browse files
committed
CLN: Replace warnings with Pandas4Warning
1 parent 78ec276 commit e750d50

File tree

12 files changed

+24
-10
lines changed

12 files changed

+24
-10
lines changed

pandas/_libs/tslibs/offsets.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5192,6 +5192,7 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str:
51925192
if name in _lite_rule_alias:
51935193
return name
51945194
if name in c_PERIOD_AND_OFFSET_DEPR_FREQSTR:
5195+
# TODO: Enforce in 3.0 (#59240)
51955196
warnings.warn(
51965197
f"\'{name}\' is deprecated and will be removed "
51975198
f"in a future version, please use "
@@ -5206,6 +5207,7 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str:
52065207
if name == _name:
52075208
continue
52085209
if _name in c_PERIOD_AND_OFFSET_DEPR_FREQSTR.values():
5210+
# TODO: Enforce in 3.0 (#59240)
52095211
warnings.warn(
52105212
f"\'{name}\' is deprecated and will be removed "
52115213
f"in a future version, please use "

pandas/_libs/tslibs/period.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,6 +3018,7 @@ class Period(_Period):
30183018
# GH#53446
30193019
import warnings
30203020

3021+
# TODO: Enforce in 3.0 (#53511)
30213022
from pandas.util._exceptions import find_stack_level
30223023
warnings.warn(
30233024
"Period with BDay freq is deprecated and will be removed "

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,7 @@ cpdef inline str parse_timedelta_unit(str unit):
722722
elif unit == "M":
723723
return unit
724724
elif unit in c_DEPR_UNITS:
725+
# TODO: Enforce in 3.0 (#59240)
725726
warnings.warn(
726727
f"\'{unit}\' is deprecated and will be removed in a "
727728
f"future version. Please use \'{c_DEPR_UNITS.get(unit)}\' "

pandas/core/arrays/arrow/array.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ def _logical_method(self, other, op) -> Self:
930930
and isinstance(other, np.ndarray)
931931
and other.dtype == bool
932932
):
933+
# TODO: Enforce in 3.0 (#60234)
933934
# GH#60234 backward compatibility for the move to StringDtype in 3.0
934935
op_name = op.__name__[1:].strip("_")
935936
warnings.warn(

pandas/core/arrays/string_.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
pa_version_under12p1,
3030
)
3131
from pandas.compat.numpy import function as nv
32+
from pandas.errors import Pandas4Warning
3233
from pandas.util._decorators import (
3334
doc,
3435
set_module,
@@ -167,6 +168,7 @@ def __init__(
167168
storage = "python"
168169

169170
if storage == "pyarrow_numpy":
171+
# TODO: Enforce in 3.0 (#60152)
170172
warnings.warn(
171173
"The 'pyarrow_numpy' storage option name is deprecated and will be "
172174
'removed in pandas 3.0. Use \'pd.StringDtype(storage="pyarrow", '
@@ -400,7 +402,7 @@ def _logical_method(self, other, op):
400402
f"'{op_name}' operations between boolean dtype and {self.dtype} are "
401403
"deprecated and will raise in a future version. Explicitly "
402404
"cast the strings to a boolean dtype before operating instead.",
403-
FutureWarning,
405+
Pandas4Warning,
404406
stacklevel=find_stack_level(),
405407
)
406408
return op(other, self.astype(bool))

pandas/core/arrays/string_arrow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ def insert(self, loc: int, item) -> ArrowStringArray:
228228

229229
def _convert_bool_result(self, values, na=lib.no_default, method_name=None):
230230
if na is not lib.no_default and not isna(na) and not isinstance(na, bool):
231+
# TODO: Enforce in 3.0 (#59615)
231232
# GH#59561
232233
warnings.warn(
233234
f"Allowing a non-bool 'na' in obj.str.{method_name} is deprecated "

pandas/core/frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ def __init__(
727727
f"Passing a {type(data).__name__} to {type(self).__name__} "
728728
"is deprecated and will raise in a future version. "
729729
"Use public APIs instead.",
730-
DeprecationWarning,
730+
Pandas4Warning,
731731
stacklevel=2,
732732
)
733733

@@ -9887,7 +9887,7 @@ def stack(
98879887
"removed in a future version of pandas. See the What's New notes "
98889888
"for pandas 2.1.0 for details. Do not specify the future_stack "
98899889
"argument to adopt the new implementation and silence this warning.",
9890-
FutureWarning,
9890+
Pandas4Warning,
98919891
stacklevel=find_stack_level(),
98929892
)
98939893

pandas/core/generic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9133,6 +9133,7 @@ def resample(
91339133
from pandas.core.resample import get_resampler
91349134

91359135
if convention is not lib.no_default:
9136+
# TODO: Enforce in 3.0 (#55968)
91369137
warnings.warn(
91379138
f"The 'convention' keyword in {type(self).__name__}.resample is "
91389139
"deprecated and will be removed in a future version. "

pandas/core/internals/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from pandas.errors import Pandas4Warning
2+
13
from pandas.core.internals.api import make_block # 2023-09-18 pyarrow uses this
24
from pandas.core.internals.concat import concatenate_managers
35
from pandas.core.internals.managers import (
@@ -21,11 +23,11 @@ def __getattr__(name: str):
2123
import warnings
2224

2325
if name == "create_block_manager_from_blocks":
24-
# GH#33892
26+
# GH#33892, GH#58715
2527
warnings.warn(
2628
f"{name} is deprecated and will be removed in a future version. "
2729
"Use public APIs instead.",
28-
FutureWarning,
30+
Pandas4Warning,
2931
# https://github.com/pandas-dev/pandas/pull/55139#pullrequestreview-1720690758
3032
# on hard-coding stacklevel
3133
stacklevel=2,
@@ -42,7 +44,7 @@ def __getattr__(name: str):
4244
warnings.warn(
4345
f"{name} is deprecated and will be removed in a future version. "
4446
"Use public APIs instead.",
45-
FutureWarning,
47+
Pandas4Warning,
4648
# https://github.com/pandas-dev/pandas/pull/55139#pullrequestreview-1720690758
4749
# on hard-coding stacklevel
4850
stacklevel=2,

pandas/core/resample.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,7 @@ class PeriodIndexResampler(DatetimeIndexResampler):
19451945

19461946
@property
19471947
def _resampler_for_grouping(self):
1948+
# TODO: Enforce in 3.0 (#55968)
19481949
warnings.warn(
19491950
"Resampling a groupby with a PeriodIndex is deprecated. "
19501951
"Cast to DatetimeIndex before resampling instead.",

0 commit comments

Comments
 (0)