Skip to content

Commit 8bacb94

Browse files
committed
Merge remote-tracking branch 'upstream/main' into aijams-take-function-invalid-dtype
2 parents aa3c228 + 641ebf4 commit 8bacb94

File tree

16 files changed

+481
-158
lines changed

16 files changed

+481
-158
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ Other Deprecations
716716
- Deprecated using ``epoch`` date format in :meth:`DataFrame.to_json` and :meth:`Series.to_json`, use ``iso`` instead. (:issue:`57063`)
717717
- Deprecated allowing ``fill_value`` that cannot be held in the original dtype (excepting NA values for integer and bool dtypes) in :meth:`Series.unstack` and :meth:`DataFrame.unstack` (:issue:`12189`, :issue:`53868`)
718718
- Deprecated allowing ``fill_value`` that cannot be held in the original dtype (excepting NA values for integer and bool dtypes) in :meth:`Series.shift` and :meth:`DataFrame.shift` (:issue:`53802`)
719+
- Deprecated option "future.no_silent_downcasting", as it is no longer used. In a future version accessing this option will raise (:issue:`59502`)
719720
- Deprecated slicing on a :class:`Series` or :class:`DataFrame` with a :class:`DatetimeIndex` using a ``datetime.date`` object, explicitly cast to :class:`Timestamp` instead (:issue:`35830`)
720721

721722
.. ---------------------------------------------------------------------------
@@ -1012,12 +1013,13 @@ Strings
10121013
^^^^^^^
10131014
- Bug in :meth:`Series.str.zfill` raising ``AttributeError`` for :class:`ArrowDtype` (:issue:`61485`)
10141015
- Bug in :meth:`Series.value_counts` would not respect ``sort=False`` for series having ``string`` dtype (:issue:`55224`)
1016+
- Bug in multiplication with a :class:`StringDtype` incorrectly allowing multiplying by bools; explicitly cast to integers instead (:issue:`62595`)
10151017

10161018
Interval
10171019
^^^^^^^^
10181020
- :meth:`Index.is_monotonic_decreasing`, :meth:`Index.is_monotonic_increasing`, and :meth:`Index.is_unique` could incorrectly be ``False`` for an ``Index`` created from a slice of another ``Index``. (:issue:`57911`)
1021+
- Bug in :class:`Index`, :class:`Series`, :class:`DataFrame` constructors when given a sequence of :class:`Interval` subclass objects casting them to :class:`Interval` (:issue:`46945`)
10191022
- Bug in :func:`interval_range` where start and end numeric types were always cast to 64 bit (:issue:`57268`)
1020-
-
10211023

10221024
Indexing
10231025
^^^^^^^^

pandas/_libs/lib.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,8 @@ cpdef bint is_interval_array(ndarray values):
22552255
for i in range(n):
22562256
val = values[i]
22572257

2258-
if isinstance(val, Interval):
2258+
if type(val) is Interval:
2259+
# GH#46945 catch Interval exactly, excluding subclasses
22592260
if closed is None:
22602261
closed = val.closed
22612262
numeric = (

pandas/core/arrays/string_.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,16 @@ def _cmp_method(self, other, op):
11131113
other = np.asarray(other)
11141114
other = other[valid]
11151115

1116+
other_dtype = getattr(other, "dtype", None)
1117+
if op.__name__.strip("_") in ["mul", "rmul"] and (
1118+
lib.is_bool(other) or lib.is_np_dtype(other_dtype, "b")
1119+
):
1120+
# GH#62595
1121+
raise TypeError(
1122+
"Cannot multiply StringArray by bools. "
1123+
"Explicitly cast to integers instead."
1124+
)
1125+
11161126
if op.__name__ in ops.ARITHMETIC_BINOPS:
11171127
result = np.empty_like(self._ndarray, dtype="object")
11181128
result[mask] = self.dtype.na_value

pandas/core/config_init.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
is_text,
2929
)
3030

31+
from pandas.errors import Pandas4Warning
32+
3133
# compute
3234

3335
use_bottleneck_doc = """
@@ -899,10 +901,10 @@ def register_converter_cb(key: str) -> None:
899901
cf.register_option(
900902
"no_silent_downcasting",
901903
False,
902-
"Whether to opt-in to the future behavior which will *not* silently "
903-
"downcast results from Series and DataFrame `where`, `mask`, and `clip` "
904-
"methods. "
905-
"Silent downcasting will be removed in pandas 3.0 "
906-
"(at which point this option will be deprecated).",
904+
"This option is deprecated and will be removed in a future version. "
905+
"It has no effect.",
907906
validator=is_one_of_factory([True, False]),
908907
)
908+
909+
# GH#59502
910+
cf.deprecate_option("future.no_silent_downcasting", Pandas4Warning)

0 commit comments

Comments
 (0)