Skip to content

Commit f4e0d00

Browse files
committed
Add CurrentPandasWarning
1 parent 2570d57 commit f4e0d00

33 files changed

+116
-115
lines changed

pandas/_libs/tslibs/timestamps.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ from pandas._libs.tslibs cimport ccalendar
5151
from pandas._libs.tslibs.base cimport ABCTimestamp
5252

5353
from pandas.util._exceptions import (
54-
Pandas40DeprecationWarning,
54+
CurrentDeprecationWarning,
5555
find_stack_level,
5656
)
5757

@@ -1536,7 +1536,7 @@ class Timestamp(_Timestamp):
15361536
# GH#56680
15371537
"Timestamp.utcnow is deprecated and will be removed in a future "
15381538
"version. Use Timestamp.now('UTC') instead.",
1539-
Pandas40DeprecationWarning,
1539+
CurrentDeprecationWarning,
15401540
stacklevel=find_stack_level(),
15411541
)
15421542
return cls.now(UTC)
@@ -1564,7 +1564,7 @@ class Timestamp(_Timestamp):
15641564
# to match. GH#56680
15651565
"Timestamp.utcfromtimestamp is deprecated and will be removed in a "
15661566
"future version. Use Timestamp.fromtimestamp(ts, 'UTC') instead.",
1567-
Pandas40DeprecationWarning,
1567+
CurrentDeprecationWarning,
15681568
stacklevel=find_stack_level(),
15691569
)
15701570
return cls.fromtimestamp(ts, tz="UTC")

pandas/core/generic.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
doc,
9999
)
100100
from pandas.util._exceptions import (
101-
Pandas40DeprecationWarning,
101+
CurrentDeprecationWarning,
102102
find_stack_level,
103103
)
104104
from pandas.util._validators import (
@@ -2573,15 +2573,15 @@ def to_json(
25732573
warnings.warn(
25742574
"The default 'epoch' date format is deprecated and will be removed "
25752575
"in a future version, please use 'iso' date format instead.",
2576-
Pandas40DeprecationWarning,
2576+
CurrentDeprecationWarning,
25772577
stacklevel=find_stack_level(),
25782578
)
25792579
elif date_format == "epoch":
25802580
# GH#57063
25812581
warnings.warn(
25822582
"'epoch' date format is deprecated and will be removed in a future "
25832583
"version, please use 'iso' date format instead.",
2584-
Pandas40DeprecationWarning,
2584+
CurrentDeprecationWarning,
25852585
stacklevel=find_stack_level(),
25862586
)
25872587

@@ -4309,7 +4309,7 @@ def _check_copy_deprecation(copy):
43094309
"version. Copy-on-Write is active in pandas since 3.0 which utilizes "
43104310
"a lazy copy mechanism that defers copies until necessary. Use "
43114311
".copy() to make an eager copy if necessary.",
4312-
Pandas40DeprecationWarning,
4312+
CurrentDeprecationWarning,
43134313
stacklevel=find_stack_level(),
43144314
)
43154315

pandas/core/groupby/generic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
doc,
3535
)
3636
from pandas.util._exceptions import (
37-
Pandas40DeprecationWarning,
37+
CurrentDeprecationWarning,
3838
find_stack_level,
3939
)
4040

@@ -2794,7 +2794,7 @@ def corrwith(
27942794
"""
27952795
warnings.warn(
27962796
"DataFrameGroupBy.corrwith is deprecated",
2797-
Pandas40DeprecationWarning,
2797+
CurrentDeprecationWarning,
27982798
stacklevel=find_stack_level(),
27992799
)
28002800
result = self._op_via_apply(

pandas/core/indexes/accessors.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from pandas._libs import lib
1717
from pandas.util._exceptions import (
18-
Pandas40DeprecationWarning,
18+
CurrentDeprecationWarning,
1919
find_stack_level,
2020
)
2121

@@ -221,7 +221,7 @@ def to_pytimedelta(self):
221221
"in a future version this will return a Series containing python "
222222
"datetime.timedelta objects instead of an ndarray. To retain the "
223223
"old behavior, call `np.array` on the result",
224-
Pandas40DeprecationWarning,
224+
CurrentDeprecationWarning,
225225
stacklevel=find_stack_level(),
226226
)
227227
return cast(ArrowExtensionArray, self._parent.array)._dt_to_pytimedelta()
@@ -482,7 +482,7 @@ def to_pytimedelta(self) -> np.ndarray:
482482
"in a future version this will return a Series containing python "
483483
"datetime.timedelta objects instead of an ndarray. To retain the "
484484
"old behavior, call `np.array` on the result",
485-
Pandas40DeprecationWarning,
485+
CurrentDeprecationWarning,
486486
stacklevel=find_stack_level(),
487487
)
488488
return self._get_values().to_pytimedelta()

pandas/core/internals/api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import numpy as np
1616

1717
from pandas._libs.internals import BlockPlacement
18-
from pandas.util._exceptions import Pandas40DeprecationWarning
18+
from pandas.util._exceptions import CurrentDeprecationWarning
1919

2020
from pandas.core.dtypes.common import pandas_dtype
2121
from pandas.core.dtypes.dtypes import (
@@ -94,7 +94,7 @@ def make_block(
9494
"make_block is deprecated and will be removed in a future version. "
9595
"Use pd.api.internals.create_dataframe_from_blocks or "
9696
"(recommended) higher-level public APIs instead.",
97-
Pandas40DeprecationWarning,
97+
CurrentDeprecationWarning,
9898
stacklevel=2,
9999
)
100100

pandas/core/reshape/concat.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from pandas._libs import lib
2020
from pandas.util._decorators import cache_readonly
2121
from pandas.util._exceptions import (
22-
Pandas40DeprecationWarning,
22+
CurrentDeprecationWarning,
2323
find_stack_level,
2424
)
2525

@@ -385,7 +385,7 @@ def concat(
385385
"version. Copy-on-Write is active in pandas since 3.0 which utilizes "
386386
"a lazy copy mechanism that defers copies until necessary. Use "
387387
".copy() to make an eager copy if necessary.",
388-
Pandas40DeprecationWarning,
388+
CurrentDeprecationWarning,
389389
stacklevel=find_stack_level(),
390390
)
391391

pandas/io/feather_format.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pandas._libs import lib
1414
from pandas.compat._optional import import_optional_dependency
1515
from pandas.util._decorators import doc
16-
from pandas.util._exceptions import Pandas40DeprecationWarning
16+
from pandas.util._exceptions import CurrentDeprecationWarning
1717
from pandas.util._validators import check_dtype_backend
1818

1919
import pandas as pd
@@ -137,7 +137,7 @@ def read_feather(
137137
warnings.filterwarnings(
138138
"ignore",
139139
"make_block is deprecated",
140-
Pandas40DeprecationWarning,
140+
CurrentDeprecationWarning,
141141
)
142142

143143
return feather.read_feather(

pandas/io/parquet.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from pandas.compat._optional import import_optional_dependency
2222
from pandas.errors import AbstractMethodError
2323
from pandas.util._decorators import doc
24-
from pandas.util._exceptions import Pandas40DeprecationWarning
24+
from pandas.util._exceptions import CurrentDeprecationWarning
2525
from pandas.util._validators import check_dtype_backend
2626

2727
import pandas as pd
@@ -279,7 +279,7 @@ def read(
279279
filterwarnings(
280280
"ignore",
281281
"make_block is deprecated",
282-
Pandas40DeprecationWarning,
282+
CurrentDeprecationWarning,
283283
)
284284
result = pa_table.to_pandas(**to_pandas_kwargs)
285285

@@ -398,7 +398,7 @@ def read(
398398
filterwarnings(
399399
"ignore",
400400
"make_block is deprecated",
401-
Pandas40DeprecationWarning,
401+
CurrentDeprecationWarning,
402402
)
403403
return parquet_file.to_pandas(
404404
columns=columns, filters=filters, **kwargs

pandas/io/parsers/arrow_parser_wrapper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ParserWarning,
1313
)
1414
from pandas.util._exceptions import (
15-
Pandas40DeprecationWarning,
15+
CurrentDeprecationWarning,
1616
find_stack_level,
1717
)
1818

@@ -294,7 +294,7 @@ def read(self) -> DataFrame:
294294
warnings.filterwarnings(
295295
"ignore",
296296
"make_block is deprecated",
297-
Pandas40DeprecationWarning,
297+
CurrentDeprecationWarning,
298298
)
299299
if dtype_backend == "pyarrow":
300300
frame = table.to_pandas(types_mapper=pd.ArrowDtype)

pandas/tests/copy_view/test_copy_deprecation.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from pandas.util._exceptions import Pandas40DeprecationWarning
3+
from pandas.util._exceptions import CurrentDeprecationWarning
44

55
import pandas as pd
66
from pandas import (
@@ -40,34 +40,34 @@ def test_copy_deprecation(meth, kwargs):
4040
df = df.set_index(["b", "c"])
4141

4242
if meth != "swaplevel":
43-
with tm.assert_produces_warning(Pandas40DeprecationWarning, match="copy"):
43+
with tm.assert_produces_warning(CurrentDeprecationWarning, match="copy"):
4444
getattr(df, meth)(copy=False, **kwargs)
4545

4646
if meth != "transpose":
47-
with tm.assert_produces_warning(Pandas40DeprecationWarning, match="copy"):
47+
with tm.assert_produces_warning(CurrentDeprecationWarning, match="copy"):
4848
getattr(df.a, meth)(copy=False, **kwargs)
4949

5050

5151
def test_copy_deprecation_reindex_like_align():
5252
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
5353
# Somehow the stack level check is incorrect here
5454
with tm.assert_produces_warning(
55-
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
55+
CurrentDeprecationWarning, match="copy", check_stacklevel=False
5656
):
5757
df.reindex_like(df, copy=False)
5858

5959
with tm.assert_produces_warning(
60-
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
60+
CurrentDeprecationWarning, match="copy", check_stacklevel=False
6161
):
6262
df.a.reindex_like(df.a, copy=False)
6363

6464
with tm.assert_produces_warning(
65-
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
65+
CurrentDeprecationWarning, match="copy", check_stacklevel=False
6666
):
6767
df.align(df, copy=False)
6868

6969
with tm.assert_produces_warning(
70-
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
70+
CurrentDeprecationWarning, match="copy", check_stacklevel=False
7171
):
7272
df.a.align(df.a, copy=False)
7373

@@ -76,16 +76,16 @@ def test_copy_deprecation_merge_concat():
7676
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
7777

7878
with tm.assert_produces_warning(
79-
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
79+
CurrentDeprecationWarning, match="copy", check_stacklevel=False
8080
):
8181
df.merge(df, copy=False)
8282

8383
with tm.assert_produces_warning(
84-
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
84+
CurrentDeprecationWarning, match="copy", check_stacklevel=False
8585
):
8686
merge(df, df, copy=False)
8787

8888
with tm.assert_produces_warning(
89-
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
89+
CurrentDeprecationWarning, match="copy", check_stacklevel=False
9090
):
9191
concat([df, df], copy=False)

pandas/tests/extension/test_arrow.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
pa_version_under13p0,
4444
pa_version_under14p0,
4545
)
46-
from pandas.util._exceptions import Pandas40DeprecationWarning
46+
from pandas.util._exceptions import CurrentDeprecationWarning
4747
import pandas.util._test_decorators as td
4848

4949
from pandas.core.dtypes.dtypes import (
@@ -2863,14 +2863,14 @@ def test_dt_to_pytimedelta():
28632863
ser = pd.Series(data, dtype=ArrowDtype(pa.duration("ns")))
28642864

28652865
msg = "The behavior of ArrowTemporalProperties.to_pytimedelta is deprecated"
2866-
with tm.assert_produces_warning(Pandas40DeprecationWarning, match=msg):
2866+
with tm.assert_produces_warning(CurrentDeprecationWarning, match=msg):
28672867
result = ser.dt.to_pytimedelta()
28682868
expected = np.array(data, dtype=object)
28692869
tm.assert_numpy_array_equal(result, expected)
28702870
assert all(type(res) is timedelta for res in result)
28712871

28722872
msg = "The behavior of TimedeltaProperties.to_pytimedelta is deprecated"
2873-
with tm.assert_produces_warning(Pandas40DeprecationWarning, match=msg):
2873+
with tm.assert_produces_warning(CurrentDeprecationWarning, match=msg):
28742874
expected = ser.astype("timedelta64[ns]").dt.to_pytimedelta()
28752875
tm.assert_numpy_array_equal(result, expected)
28762876

pandas/tests/frame/methods/test_reindex_like.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import pytest
33

4-
from pandas.util._exceptions import Pandas40DeprecationWarning
4+
from pandas.util._exceptions import CurrentDeprecationWarning
55

66
from pandas import DataFrame
77
import pandas._testing as tm
@@ -24,10 +24,10 @@ def test_reindex_like(self, float_frame):
2424
def test_reindex_like_methods(self, method, expected_values):
2525
df = DataFrame({"x": list(range(5))})
2626

27-
with tm.assert_produces_warning(Pandas40DeprecationWarning):
27+
with tm.assert_produces_warning(CurrentDeprecationWarning):
2828
result = df.reindex_like(df, method=method, tolerance=0)
2929
tm.assert_frame_equal(df, result)
30-
with tm.assert_produces_warning(Pandas40DeprecationWarning):
30+
with tm.assert_produces_warning(CurrentDeprecationWarning):
3131
result = df.reindex_like(df, method=method, tolerance=[0, 0, 0, 0])
3232
tm.assert_frame_equal(df, result)
3333

pandas/tests/groupby/test_all_methods.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import pytest
1515

16-
from pandas.util._exceptions import Pandas40DeprecationWarning
16+
from pandas.util._exceptions import CurrentDeprecationWarning
1717

1818
import pandas as pd
1919
from pandas import DataFrame
@@ -28,7 +28,7 @@ def test_multiindex_group_all_columns_when_empty(groupby_func):
2828
method = getattr(gb, groupby_func)
2929
args = get_groupby_method_args(groupby_func, df)
3030
if groupby_func == "corrwith":
31-
warn = Pandas40DeprecationWarning
31+
warn = CurrentDeprecationWarning
3232
warn_msg = "DataFrameGroupBy.corrwith is deprecated"
3333
else:
3434
warn = None
@@ -74,7 +74,7 @@ def test_dup_labels_output_shape(groupby_func, idx):
7474

7575
args = get_groupby_method_args(groupby_func, df)
7676
if groupby_func == "corrwith":
77-
warn = Pandas40DeprecationWarning
77+
warn = CurrentDeprecationWarning
7878
warn_msg = "DataFrameGroupBy.corrwith is deprecated"
7979
else:
8080
warn = None

pandas/tests/groupby/test_apply.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
import pytest
88

9-
from pandas.util._exceptions import Pandas40DeprecationWarning
9+
from pandas.util._exceptions import CurrentDeprecationWarning
1010

1111
import pandas as pd
1212
from pandas import (
@@ -1200,7 +1200,7 @@ def test_apply_is_unchanged_when_other_methods_are_called_first(reduction_func):
12001200
grp = df.groupby(by="a")
12011201
args = get_groupby_method_args(reduction_func, df)
12021202
if reduction_func == "corrwith":
1203-
warn = Pandas40DeprecationWarning
1203+
warn = CurrentDeprecationWarning
12041204
msg = "DataFrameGroupBy.corrwith is deprecated"
12051205
else:
12061206
warn = None

0 commit comments

Comments
 (0)