Skip to content

Commit 2420933

Browse files
committed
COMPAT: older numpies compat on dtype upcasting, xref pandas-dev#10503
1 parent ef6de76 commit 2420933

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pandas/core/internals.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,23 @@ def _is_empty_indexer(indexer):
717717
block = block.convert(numeric=False)
718718

719719
return block
720-
except (ValueError, TypeError):
720+
except ValueError:
721721
raise
722+
except TypeError:
723+
724+
# cast to the passed dtype if possible
725+
# otherwise raise the original error
726+
try:
727+
# e.g. we are uint32 and our value is uint64
728+
# this is for compat with older numpies
729+
block = self.make_block(transf(values.astype(value.dtype)))
730+
return block.setitem(indexer=indexer, value=value, mgr=mgr)
731+
732+
except:
733+
pass
734+
735+
raise
736+
722737
except Exception:
723738
pass
724739

0 commit comments

Comments
 (0)