Skip to content

Commit c762d73

Browse files
Merge remote-tracking branch 'upstream/master' into typing
2 parents 34bf08c + de2e086 commit c762d73

File tree

3 files changed

+7
-50
lines changed

3 files changed

+7
-50
lines changed

pandas/core/arrays/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def _from_sequence(cls, scalars, dtype=None, copy=False):
177177
dtype : dtype, optional
178178
Construct for this particular dtype. This should be a Dtype
179179
compatible with the ExtensionArray.
180-
copy : boolean, default False
180+
copy : bool, default False
181181
If True, copy the underlying data.
182182
183183
Returns
@@ -200,7 +200,7 @@ def _from_sequence_of_strings(cls, strings, dtype=None, copy=False):
200200
dtype : dtype, optional
201201
Construct for this particular dtype. This should be a Dtype
202202
compatible with the ExtensionArray.
203-
copy : boolean, default False
203+
copy : bool, default False
204204
If True, copy the underlying data.
205205
206206
Returns
@@ -771,7 +771,7 @@ def take(
771771
772772
Parameters
773773
----------
774-
indices : sequence of integers
774+
indices : sequence of int
775775
Indices to be taken.
776776
allow_fill : bool, default False
777777
How to handle negative values in `indices`.

pandas/core/dtypes/cast.py

+3-46
Original file line numberDiff line numberDiff line change
@@ -424,57 +424,14 @@ def maybe_promote(dtype, fill_value=np.nan):
424424
if issubclass(dtype.type, np.bool_):
425425
dtype = np.dtype(np.object_)
426426
elif issubclass(dtype.type, np.integer):
427-
# upcast to prevent overflow
428-
mst = np.min_scalar_type(fill_value)
429-
if mst > dtype:
430-
# np.dtype ordering considers:
431-
# int[n] < int[2*n]
432-
# uint[n] < uint[2*n]
433-
# u?int[n] < object_
434-
dtype = mst
435-
436-
elif np.can_cast(fill_value, dtype):
437-
pass
438-
439-
elif dtype.kind == "u" and mst.kind == "i":
427+
if not np.can_cast(fill_value, dtype):
428+
# upcast to prevent overflow
429+
mst = np.min_scalar_type(fill_value)
440430
dtype = np.promote_types(dtype, mst)
441431
if dtype.kind == "f":
442432
# Case where we disagree with numpy
443433
dtype = np.dtype(np.object_)
444434

445-
elif dtype.kind == "i" and mst.kind == "u":
446-
447-
if fill_value > np.iinfo(np.int64).max:
448-
# object is the only way to represent fill_value and keep
449-
# the range allowed by the given dtype
450-
dtype = np.dtype(np.object_)
451-
452-
elif mst.itemsize < dtype.itemsize:
453-
pass
454-
455-
elif dtype.itemsize == mst.itemsize:
456-
# We never cast signed to unsigned because that loses
457-
# parts of the original range, so find the smallest signed
458-
# integer that can hold all of `mst`.
459-
ndt = {
460-
np.int64: np.object_,
461-
np.int32: np.int64,
462-
np.int16: np.int32,
463-
np.int8: np.int16,
464-
}[dtype.type]
465-
dtype = np.dtype(ndt)
466-
467-
else:
468-
# bump to signed integer dtype that holds all of `mst` range
469-
# Note: we have to use itemsize because some (windows)
470-
# builds don't satisfiy e.g. np.uint32 == np.uint32
471-
ndt = {
472-
4: np.int64,
473-
2: np.int32,
474-
1: np.int16, # TODO: Test for this case
475-
}[mst.itemsize]
476-
dtype = np.dtype(ndt)
477-
478435
fill_value = dtype.type(fill_value)
479436

480437
elif issubclass(dtype.type, np.floating):

pandas/io/formats/style.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ def set_table_attributes(self, attributes):
789789
790790
Parameters
791791
----------
792-
attributes : string
792+
attributes : str
793793
794794
Returns
795795
-------

0 commit comments

Comments
 (0)