Skip to content

Commit 016c2f1

Browse files
authored
Merge branch 'main' into remove-doc-decorators2
2 parents 2ba57e0 + a885d67 commit 016c2f1

File tree

30 files changed

+496
-584
lines changed

30 files changed

+496
-584
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,13 @@ Other API changes
750750
- :class:`Series` "flex" methods like :meth:`Series.add` no longer allow passing a :class:`DataFrame` for ``other``; use the DataFrame reversed method instead (:issue:`46179`)
751751
- :meth:`CategoricalIndex.append` no longer attempts to cast different-dtype indexes to the caller's dtype (:issue:`41626`)
752752
- :meth:`ExtensionDtype.construct_array_type` is now a regular method instead of a ``classmethod`` (:issue:`58663`)
753+
- Arithmetic operations between a :class:`Series`, :class:`Index`, or :class:`ExtensionArray` with a ``list`` now consistently wrap that list with an array equivalent to ``Series(my_list).array``. To do any other kind of type inference or casting, do so explicitly before operating (:issue:`62552`)
753754
- 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`)
754755
- 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`)
756+
- Methods that can operate in-place (:meth:`~DataFrame.replace`, :meth:`~DataFrame.fillna`,
757+
:meth:`~DataFrame.ffill`, :meth:`~DataFrame.bfill`, :meth:`~DataFrame.interpolate`,
758+
:meth:`~DataFrame.where`, :meth:`~DataFrame.mask`, :meth:`~DataFrame.clip`) now return
759+
the modified DataFrame or Series (``self``) instead of ``None`` when ``inplace=True`` (:issue:`63207`)
755760

756761
.. ---------------------------------------------------------------------------
757762
.. _whatsnew_300.deprecations:

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ from pandas._libs.tslibs.offsets import Day
8383

8484
from pandas._libs.tslibs.util cimport (
8585
is_array,
86+
is_bool_object,
8687
is_float_object,
8788
is_integer_object,
8889
)
@@ -2311,6 +2312,13 @@ class Timedelta(_Timedelta):
23112312
return self.__mul__(item)
23122313
return other * self.to_timedelta64()
23132314

2315+
elif is_bool_object(other):
2316+
# GH#62316
2317+
raise TypeError(
2318+
"Cannot multiply Timedelta by bool. "
2319+
"Explicitly cast to integer instead."
2320+
)
2321+
23142322
return NotImplemented
23152323

23162324
__rmul__ = __mul__

pandas/core/arrays/masked.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,9 @@ def _maybe_mask_result(
10171017

10181018
return IntegerArray(result, mask, copy=False)
10191019

1020+
elif result.dtype == object:
1021+
result[mask] = self.dtype.na_value
1022+
return result
10201023
else:
10211024
result[mask] = np.nan
10221025
return result

pandas/core/frame.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6109,19 +6109,9 @@ def pop(self, item: Hashable) -> Series:
61096109
"""
61106110
return super().pop(item=item)
61116111

6112-
@overload
6113-
def _replace_columnwise(
6114-
self, mapping: dict[Hashable, tuple[Any, Any]], inplace: Literal[True], regex
6115-
) -> None: ...
6116-
6117-
@overload
6118-
def _replace_columnwise(
6119-
self, mapping: dict[Hashable, tuple[Any, Any]], inplace: Literal[False], regex
6120-
) -> Self: ...
6121-
61226112
def _replace_columnwise(
61236113
self, mapping: dict[Hashable, tuple[Any, Any]], inplace: bool, regex
6124-
) -> Self | None:
6114+
) -> Self:
61256115
"""
61266116
Dispatch to Series.replace column-wise.
61276117
@@ -6134,7 +6124,7 @@ def _replace_columnwise(
61346124
61356125
Returns
61366126
-------
6137-
DataFrame or None
6127+
DataFrame
61386128
"""
61396129
# Operate column-wise
61406130
res = self if inplace else self.copy(deep=False)
@@ -6149,9 +6139,7 @@ def _replace_columnwise(
61496139

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

6152-
if inplace:
6153-
return None
6154-
return res.__finalize__(self)
6142+
return res if inplace else res.__finalize__(self)
61556143

61566144
@doc(NDFrame.shift, klass=_shared_doc_kwargs["klass"])
61576145
def shift(

0 commit comments

Comments
 (0)