Skip to content

Commit a775f9c

Browse files
barnarghbarnargh
barnargh
authored and
barnargh
committed
fixed implicit conversion of 1-arrays inside data frames
1 parent 4afc277 commit a775f9c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pandas/core/internals/managers.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2170,8 +2170,10 @@ def setitem_inplace(self, indexer, value) -> None:
21702170
# Note: checking for ndarray instead of np.dtype means we exclude
21712171
# dt64/td64, which do their own validation.
21722172
value = np_can_hold_element(arr.dtype, value)
2173-
2174-
if isinstance(value, np.ndarray) and value.ndim == 1 and len(value) == 1:
2173+
2174+
# check if the dtype of the block is object
2175+
implicit_convert = arr.dtype != 'object'
2176+
if isinstance(value, np.ndarray) and value.ndim == 1 and len(value) == 1 and implicit_convert:
21752177
# NumPy 1.25 deprecation: https://github.com/numpy/numpy/pull/10615
21762178
value = value[0, ...]
21772179

0 commit comments

Comments
 (0)