Skip to content

Commit 3222d60

Browse files
committed
BUG: is_float(e) and e.is_integer() added to IntBlock._can_hold_element
As @jbrockmendel said in #35376, you can replace an int by a float in an IntBlock only if the element is an integer.
1 parent cf5fc6d commit 3222d60

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pandas/core/internals/blocks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2067,7 +2067,7 @@ def _can_hold_element(self, element: Any) -> bool:
20672067
and not issubclass(tipo.type, (np.datetime64, np.timedelta64))
20682068
and self.dtype.itemsize >= tipo.itemsize
20692069
)
2070-
return is_integer(element) or is_float(element)
2070+
return is_integer(element) or (is_float(element) and element.is_integer())
20712071

20722072

20732073
class DatetimeLikeBlockMixin:

0 commit comments

Comments
 (0)