Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
4 changes: 4 additions & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,10 @@ Other API changes
- :meth:`ExtensionDtype.construct_array_type` is now a regular method instead of a ``classmethod`` (:issue:`58663`)
- Comparison operations between :class:`Index` and :class:`Series` now consistently return :class:`Series` regardless of which object is on the left or right (:issue:`36759`)
- Numpy functions like ``np.isinf`` that return a bool dtype when called on a :class:`Index` object now return a bool-dtype :class:`Index` instead of ``np.ndarray`` (:issue:`52676`)
- Methods that can operate in-place (:meth:`~DataFrame.replace`, :meth:`~DataFrame.fillna`,
:meth:`~DataFrame.ffill`, :meth:`~DataFrame.bfill`, :meth:`~DataFrame.interpolate`,
:meth:`~DataFrame.where`, :meth:`~DataFrame.mask`, :meth:`~DataFrame.clip`) now return
the modified DataFrame or Series (``self``) instead of ``None`` when ``inplace=True`` (:issue:`63207`)

.. ---------------------------------------------------------------------------
.. _whatsnew_300.deprecations:
Expand Down
18 changes: 3 additions & 15 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6054,19 +6054,9 @@ def pop(self, item: Hashable) -> Series:
"""
return super().pop(item=item)

@overload
def _replace_columnwise(
self, mapping: dict[Hashable, tuple[Any, Any]], inplace: Literal[True], regex
) -> None: ...

@overload
def _replace_columnwise(
self, mapping: dict[Hashable, tuple[Any, Any]], inplace: Literal[False], regex
) -> Self: ...

def _replace_columnwise(
self, mapping: dict[Hashable, tuple[Any, Any]], inplace: bool, regex
) -> Self | None:
) -> Self:
"""
Dispatch to Series.replace column-wise.

Expand All @@ -6079,7 +6069,7 @@ def _replace_columnwise(

Returns
-------
DataFrame or None
DataFrame
"""
# Operate column-wise
res = self if inplace else self.copy(deep=False)
Expand All @@ -6094,9 +6084,7 @@ def _replace_columnwise(

res._iset_item(i, newobj, inplace=inplace)

if inplace:
return None
return res.__finalize__(self)
return res if inplace else res.__finalize__(self)

@doc(NDFrame.shift, klass=_shared_doc_kwargs["klass"])
def shift(
Expand Down
Loading
Loading