Skip to content

Commit 50d2ce6

Browse files
committed
Merge remote-tracking branch 'upstream/main' into tst/unused_fixtures
2 parents 378b1b4 + e950e00 commit 50d2ce6

File tree

10 files changed

+348
-322
lines changed

10 files changed

+348
-322
lines changed

pandas/core/array_algos/putmask.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
ArrayLike,
1313
npt,
1414
)
15+
from pandas.compat import np_version_under1p20
1516

1617
from pandas.core.dtypes.cast import (
1718
can_hold_element,
@@ -126,7 +127,8 @@ def putmask_without_repeat(
126127
mask : np.ndarray[bool]
127128
new : Any
128129
"""
129-
new = setitem_datetimelike_compat(values, mask.sum(), new)
130+
if np_version_under1p20:
131+
new = setitem_datetimelike_compat(values, mask.sum(), new)
130132

131133
if getattr(new, "ndim", 0) >= 1:
132134
new = new.astype(values.dtype, copy=False)

pandas/core/arrays/_mixins.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@ def _values_for_argsort(self) -> np.ndarray:
180180
def argmin(self, axis: int = 0, skipna: bool = True): # type:ignore[override]
181181
# override base class by adding axis keyword
182182
validate_bool_kwarg(skipna, "skipna")
183-
if not skipna and self.isna().any():
183+
if not skipna and self._hasna:
184184
raise NotImplementedError
185185
return nargminmax(self, "argmin", axis=axis)
186186

187187
# Signature of "argmax" incompatible with supertype "ExtensionArray"
188188
def argmax(self, axis: int = 0, skipna: bool = True): # type:ignore[override]
189189
# override base class by adding axis keyword
190190
validate_bool_kwarg(skipna, "skipna")
191-
if not skipna and self.isna().any():
191+
if not skipna and self._hasna:
192192
raise NotImplementedError
193193
return nargminmax(self, "argmax", axis=axis)
194194

pandas/core/arrays/datetimes.py

-1
Original file line numberDiff line numberDiff line change
@@ -2289,7 +2289,6 @@ def maybe_convert_dtype(data, copy: bool):
22892289
copy = False
22902290

22912291
elif is_extension_array_dtype(data.dtype) and not is_datetime64tz_dtype(data.dtype):
2292-
# Includes categorical
22932292
# TODO: We have no tests for these
22942293
data = np.array(data, dtype=np.object_)
22952294
copy = False

pandas/core/internals/blocks.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,16 @@ def iget(self, i: int | tuple[int, int] | tuple[slice, int]):
367367
# "Union[int, integer[Any]]"
368368
return self.values[i] # type: ignore[index]
369369

370-
def set_inplace(self, locs, values) -> None:
370+
def set_inplace(self, locs, values: ArrayLike) -> None:
371371
"""
372372
Modify block values in-place with new item value.
373373
374374
Notes
375375
-----
376-
`set` never creates a new array or new Block, whereas `setitem` _may_
377-
create a new array and always creates a new Block.
376+
`set_inplace` never creates a new array or new Block, whereas `setitem`
377+
_may_ create a new array and always creates a new Block.
378+
379+
Caller is responsible for checking values.dtype == self.dtype.
378380
"""
379381
self.values[locs] = values
380382

@@ -1181,7 +1183,7 @@ def where(self, other, cond) -> list[Block]:
11811183
icond, noop = validate_putmask(values, ~cond)
11821184
if noop:
11831185
# GH-39595: Always return a copy; short-circuit up/downcasting
1184-
return self.copy()
1186+
return [self.copy()]
11851187

11861188
if other is lib.no_default:
11871189
other = self.fill_value
@@ -1373,7 +1375,8 @@ def setitem(self, indexer, value):
13731375

13741376
values = self.values
13751377
if values.ndim == 2:
1376-
# TODO: string[pyarrow] tests break if we transpose unconditionally
1378+
# TODO(GH#45419): string[pyarrow] tests break if we transpose
1379+
# unconditionally
13771380
values = values.T
13781381
check_setitem_lengths(indexer, value, values)
13791382
values[indexer] = value
@@ -1394,7 +1397,7 @@ def where(self, other, cond) -> list[Block]:
13941397
if noop:
13951398
# GH#44181, GH#45135
13961399
# Avoid a) raising for Interval/PeriodDtype and b) unnecessary object upcast
1397-
return self.copy()
1400+
return [self.copy()]
13981401

13991402
try:
14001403
res_values = arr._where(cond, other).T
@@ -1596,12 +1599,16 @@ def iget(self, i: int | tuple[int, int] | tuple[slice, int]):
15961599
raise IndexError(f"{self} only contains one item")
15971600
return self.values
15981601

1599-
def set_inplace(self, locs, values) -> None:
1602+
def set_inplace(self, locs, values: ArrayLike) -> None:
16001603
# NB: This is a misnomer, is supposed to be inplace but is not,
16011604
# see GH#33457
16021605
# When an ndarray, we should have locs.tolist() == [0]
16031606
# When a BlockPlacement we should have list(locs) == [0]
1604-
self.values = values
1607+
1608+
# error: Incompatible types in assignment (expression has type
1609+
# "Union[ExtensionArray, ndarray[Any, Any]]", variable has type
1610+
# "ExtensionArray")
1611+
self.values = values # type: ignore[assignment]
16051612
try:
16061613
# TODO(GH33457) this can be removed
16071614
self._cache.clear()

pandas/core/reshape/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# flake8: noqa:F401
22

33
from pandas.core.reshape.concat import concat
4+
from pandas.core.reshape.encoding import get_dummies
45
from pandas.core.reshape.melt import (
56
lreshape,
67
melt,
@@ -16,7 +17,6 @@
1617
pivot,
1718
pivot_table,
1819
)
19-
from pandas.core.reshape.reshape import get_dummies
2020
from pandas.core.reshape.tile import (
2121
cut,
2222
qcut,

0 commit comments

Comments
 (0)