Skip to content

ENH: Implement PDEP-17 #61468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
80edcb3
ENH: Implement PDEP-17
Aloqeely Apr 5, 2024
054398d
Refinements
rhshadrach May 20, 2025
4e46d69
Refinements
rhshadrach May 21, 2025
3f3293f
Fixup
rhshadrach May 21, 2025
cac0126
Merge branch 'main' of https://github.com/pandas-dev/pandas into impl…
rhshadrach Jun 2, 2025
638ca5b
Refinements
rhshadrach Jun 2, 2025
e2960b6
Add implementation details to PDEP-17
rhshadrach Jun 2, 2025
92a4e7e
API test fixup
rhshadrach Jun 2, 2025
6bca579
Refinements
rhshadrach Jun 4, 2025
3b9617d
Update doc/source/whatsnew/v3.0.0.rst
rhshadrach Jun 26, 2025
ae2c9ae
xfail pandas_datareader
rhshadrach Jul 13, 2025
087dba6
Update web/pandas/pdeps/0017-backwards-compatibility-and-deprecation-…
rhshadrach Jul 19, 2025
a6edff6
Merge branch 'main' into implement_pdep17
rhshadrach Jul 19, 2025
25405f2
Debug docs build
rhshadrach Jul 19, 2025
9df8b32
Revert
rhshadrach Jul 19, 2025
31b2460
Debug docs build
rhshadrach Jul 19, 2025
8e85f5c
Debug docs build
rhshadrach Jul 19, 2025
ce08582
Fixup & revert
rhshadrach Jul 21, 2025
f93374c
Merge branch 'main' of https://github.com/pandas-dev/pandas into impl…
rhshadrach Jul 21, 2025
1fcdd4a
Try removing file
rhshadrach Jul 21, 2025
ee3f4f2
Restore v0.23.0
rhshadrach Jul 27, 2025
871b88a
Merge branch 'main' of https://github.com/pandas-dev/pandas into impl…
rhshadrach Jul 27, 2025
dbb7e46
Cleanup v0.23.0.rst
rhshadrach Jul 27, 2025
f45b45a
Debug
rhshadrach Jul 27, 2025
d984c1c
Debug
rhshadrach Jul 27, 2025
a92650d
Debug
rhshadrach Jul 27, 2025
a034332
Debug
rhshadrach Jul 27, 2025
0b0a850
Debug
rhshadrach Jul 27, 2025
747f5ce
Debug
rhshadrach Jul 27, 2025
0b111fa
No whammies!
rhshadrach Jul 27, 2025
7273d4f
Finish up
rhshadrach Jul 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/source/reference/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ Exceptions and warnings
errors.OptionError
errors.OutOfBoundsDatetime
errors.OutOfBoundsTimedelta
errors.PandasChangeWarning
errors.Pandas4Warning
errors.Pandas5Warning
errors.PandasPendingDeprecationWarning
errors.PandasDeprecationWarning
errors.PandasFutureWarning
errors.ParserError
errors.ParserWarning
errors.PerformanceWarning
Expand Down
10 changes: 10 additions & 0 deletions doc/source/whatsnew/v0.23.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ Please note that the string ``index`` is not supported with the round trip forma
.. ipython:: python
:okwarning:

df = pd.DataFrame(
{
'foo': [1, 2, 3, 4],
'bar': ['a', 'b', 'c', 'd'],
'baz': pd.date_range('2018-01-01', freq='d', periods=4),
'qux': pd.Categorical(['a', 'b', 'c', 'c'])
},
index=pd.Index(range(4), name='idx')
)

df.index.name = 'index'
Comment on lines +108 to 118
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this worked on main, but it seems to fix the docs build issue here.


df.to_json('test.json', orient='table')
Expand Down
12 changes: 12 additions & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ Enhancement1
Enhancement2
^^^^^^^^^^^^

New Deprecation Policy
^^^^^^^^^^^^^^^^^^^^^^
pandas 3.0.0 introduces a new 3-stage deprecation policy: using ``DeprecationWarning`` initially, then switching to ``FutureWarning`` for broader visibility in the last minor version before the next major release, and then removal of the deprecated functionality in the major release. This was done to give downstream packages more time to adjust to pandas deprecations, which should reduce the amount of warnings that a user gets from code that isn't theirs. See `PDEP 17 <https://pandas.pydata.org/pdeps/0017-backwards-compatibility-and-deprecation-policy.html>`_ for more details.

All warnings for upcoming changes in pandas will have the base class :class:`pandas.errors.PandasChangeWarning`. Users may also use the following subclasses to control warnings.

- :class:`pandas.errors.Pandas4Warning`: Warnings which will be enforced in pandas 4.0.
- :class:`pandas.errors.Pandas5Warning`: Warnings which will be enforced in pandas 5.0.
- :class:`pandas.errors.PandasPendingDeprecationWarning`: Base class of all warnings which emit a ``PendingDeprecationWarning``, independent of the version they will be enforced.
- :class:`pandas.errors.PandasDeprecationWarning`: Base class of all warnings which emit a ``DeprecationWarning``, independent of the version they will be enforced.
- :class:`pandas.errors.PandasFutureWarning`: Base class of all warnings which emit a ``PandasFutureWarning``, independent of the version they will be enforced.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- :class:`pandas.errors.PandasFutureWarning`: Base class of all warnings which emit a ``PandasFutureWarning``, independent of the version they will be enforced.
- :class:`pandas.errors.PandasFutureWarning`: Base class of all warnings which emit a ``FutureWarning``, independent of the version they will be enforced.


.. _whatsnew_300.enhancements.other:

Other enhancements
Expand Down
8 changes: 6 additions & 2 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1994,12 +1994,14 @@ class Timestamp(_Timestamp):
>>> pd.Timestamp.utcnow() # doctest: +SKIP
Timestamp('2020-11-16 22:50:18.092888+0000', tz='UTC')
"""
from pandas.errors import Pandas4Warning

warnings.warn(
# The stdlib datetime.utcnow is deprecated, so we deprecate to match.
# GH#56680
"Timestamp.utcnow is deprecated and will be removed in a future "
"version. Use Timestamp.now('UTC') instead.",
FutureWarning,
Pandas4Warning,
stacklevel=find_stack_level(),
)
return cls.now(UTC)
Expand Down Expand Up @@ -2036,13 +2038,15 @@ class Timestamp(_Timestamp):
>>> pd.Timestamp.utcfromtimestamp(1584199972)
Timestamp('2020-03-14 15:32:52+0000', tz='UTC')
"""
from pandas.errors import Pandas4Warning

# GH#22451
warnings.warn(
# The stdlib datetime.utcfromtimestamp is deprecated, so we deprecate
# to match. GH#56680
"Timestamp.utcfromtimestamp is deprecated and will be removed in a "
"future version. Use Timestamp.fromtimestamp(ts, 'UTC') instead.",
FutureWarning,
Pandas4Warning,
stacklevel=find_stack_level(),
)
return cls.fromtimestamp(ts, tz="UTC")
Expand Down
27 changes: 15 additions & 12 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from pandas.errors import (
ChainedAssignmentError,
InvalidIndexError,
Pandas4Warning,
)
from pandas.errors.cow import (
_chained_assignment_method_msg,
Expand Down Expand Up @@ -11970,7 +11971,7 @@ def all(
**kwargs,
) -> Series | bool: ...

@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="all")
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="all")
@doc(make_doc("all", ndim=1))
def all(
self,
Expand Down Expand Up @@ -12017,7 +12018,7 @@ def min(
**kwargs,
) -> Series | Any: ...

@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="min")
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="min")
@doc(make_doc("min", ndim=2))
def min(
self,
Expand Down Expand Up @@ -12064,7 +12065,7 @@ def max(
**kwargs,
) -> Series | Any: ...

@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="max")
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="max")
@doc(make_doc("max", ndim=2))
def max(
self,
Expand All @@ -12080,7 +12081,7 @@ def max(
result = result.__finalize__(self, method="max")
return result

@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="sum")
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="sum")
def sum(
self,
axis: Axis | None = 0,
Expand Down Expand Up @@ -12181,7 +12182,7 @@ def sum(
result = result.__finalize__(self, method="sum")
return result

@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="prod")
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="prod")
def prod(
self,
axis: Axis | None = 0,
Expand Down Expand Up @@ -12299,7 +12300,7 @@ def mean(
**kwargs,
) -> Series | Any: ...

@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="mean")
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="mean")
@doc(make_doc("mean", ndim=2))
def mean(
self,
Expand Down Expand Up @@ -12346,7 +12347,9 @@ def median(
**kwargs,
) -> Series | Any: ...

@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="median")
@deprecate_nonkeyword_arguments(
Pandas4Warning, allowed_args=["self"], name="median"
)
@doc(make_doc("median", ndim=2))
def median(
self,
Expand Down Expand Up @@ -12396,7 +12399,7 @@ def sem(
**kwargs,
) -> Series | Any: ...

@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="sem")
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="sem")
def sem(
self,
axis: Axis | None = 0,
Expand Down Expand Up @@ -12516,7 +12519,7 @@ def var(
**kwargs,
) -> Series | Any: ...

@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="var")
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="var")
def var(
self,
axis: Axis | None = 0,
Expand Down Expand Up @@ -12635,7 +12638,7 @@ def std(
**kwargs,
) -> Series | Any: ...

@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="std")
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="std")
def std(
self,
axis: Axis | None = 0,
Expand Down Expand Up @@ -12758,7 +12761,7 @@ def skew(
**kwargs,
) -> Series | Any: ...

@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="skew")
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="skew")
def skew(
self,
axis: Axis | None = 0,
Expand Down Expand Up @@ -12878,7 +12881,7 @@ def kurt(
**kwargs,
) -> Series | Any: ...

@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="kurt")
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="kurt")
def kurt(
self,
axis: Axis | None = 0,
Expand Down
9 changes: 5 additions & 4 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
AbstractMethodError,
ChainedAssignmentError,
InvalidIndexError,
Pandas4Warning,
)
from pandas.errors.cow import _chained_assignment_method_msg
from pandas.util._decorators import (
Expand Down Expand Up @@ -2589,15 +2590,15 @@ def to_json(
warnings.warn(
"The default 'epoch' date format is deprecated and will be removed "
"in a future version, please use 'iso' date format instead.",
FutureWarning,
Pandas4Warning,
stacklevel=find_stack_level(),
)
elif date_format == "epoch":
# GH#57063
warnings.warn(
"'epoch' date format is deprecated and will be removed in a future "
"version, please use 'iso' date format instead.",
FutureWarning,
Pandas4Warning,
stacklevel=find_stack_level(),
)

Expand Down Expand Up @@ -4376,12 +4377,12 @@ def _check_copy_deprecation(copy):
"version. Copy-on-Write is active in pandas since 3.0 which utilizes "
"a lazy copy mechanism that defers copies until necessary. Use "
".copy() to make an eager copy if necessary.",
DeprecationWarning,
Pandas4Warning,
stacklevel=find_stack_level(),
)

# issue 58667
@deprecate_kwarg("method", None)
@deprecate_kwarg(Pandas4Warning, "method", new_arg_name=None)
@final
def reindex_like(
self,
Expand Down
7 changes: 5 additions & 2 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@

from pandas._libs import Interval
from pandas._libs.hashtable import duplicated
from pandas.errors import SpecificationError
from pandas.errors import (
Pandas4Warning,
SpecificationError,
)
from pandas.util._decorators import (
Appender,
Substitution,
Expand Down Expand Up @@ -3332,7 +3335,7 @@ def corrwith(
"""
warnings.warn(
"DataFrameGroupBy.corrwith is deprecated",
FutureWarning,
Pandas4Warning,
stacklevel=find_stack_level(),
)
result = self._op_via_apply(
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/indexes/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import numpy as np

from pandas._libs import lib
from pandas.errors import Pandas4Warning
from pandas.util._exceptions import find_stack_level

from pandas.core.dtypes.common import (
Expand Down Expand Up @@ -218,7 +219,7 @@ def to_pytimedelta(self):
"in a future version this will return a Series containing python "
"datetime.timedelta objects instead of an ndarray. To retain the "
"old behavior, call `np.array` on the result",
FutureWarning,
Pandas4Warning,
stacklevel=find_stack_level(),
)
return cast(ArrowExtensionArray, self._parent.array)._dt_to_pytimedelta()
Expand Down Expand Up @@ -501,7 +502,7 @@ def to_pytimedelta(self) -> np.ndarray:
"in a future version this will return a Series containing python "
"datetime.timedelta objects instead of an ndarray. To retain the "
"old behavior, call `np.array` on the result",
FutureWarning,
Pandas4Warning,
stacklevel=find_stack_level(),
)
return self._get_values().to_pytimedelta()
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/internals/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import numpy as np

from pandas._libs.internals import BlockPlacement
from pandas.errors import Pandas4Warning

from pandas.core.dtypes.common import pandas_dtype
from pandas.core.dtypes.dtypes import (
Expand Down Expand Up @@ -102,7 +103,7 @@ def make_block(
"make_block is deprecated and will be removed in a future version. "
"Use pd.api.internals.create_dataframe_from_blocks or "
"(recommended) higher-level public APIs instead.",
DeprecationWarning,
Pandas4Warning,
stacklevel=2,
)

Expand Down
3 changes: 2 additions & 1 deletion pandas/core/reshape/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import numpy as np

from pandas._libs import lib
from pandas.errors import Pandas4Warning
from pandas.util._decorators import set_module
from pandas.util._exceptions import find_stack_level

Expand Down Expand Up @@ -392,7 +393,7 @@ def concat(
"version. Copy-on-Write is active in pandas since 3.0 which utilizes "
"a lazy copy mechanism that defers copies until necessary. Use "
".copy() to make an eager copy if necessary.",
DeprecationWarning,
Pandas4Warning,
stacklevel=find_stack_level(),
)
if join == "outer":
Expand Down
Loading
Loading