Skip to content

Commit cf5fc6d

Browse files
committed
BUG: is_float added to IntBlock._can_hold_element
Added return is_integer(element) or is_float(element) to the IntBlock._can_hold_element method because an Block of ints can be replaced from int. Read pandas-dev#35376 for more info
1 parent d6678d1 commit cf5fc6d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pandas/core/internals/blocks.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
is_extension_array_dtype,
3939
is_float_dtype,
4040
is_integer,
41+
is_float,
4142
is_integer_dtype,
4243
is_interval_dtype,
4344
is_list_like,
@@ -2066,7 +2067,7 @@ def _can_hold_element(self, element: Any) -> bool:
20662067
and not issubclass(tipo.type, (np.datetime64, np.timedelta64))
20672068
and self.dtype.itemsize >= tipo.itemsize
20682069
)
2069-
return is_integer(element)
2070+
return is_integer(element) or is_float(element)
20702071

20712072

20722073
class DatetimeLikeBlockMixin:

0 commit comments

Comments
 (0)