Skip to content

Commit d763acf

Browse files
committed
fixup! BUG: 2D ndarray of dtype 'object' is always copied upon construction (pandas-dev#39263)
1 parent 7bbc25c commit d763acf

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

doc/source/whatsnew/v1.3.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ Datetimelike
280280
- Bug in comparisons between :class:`Timestamp` object and ``datetime64`` objects just outside the implementation bounds for nanosecond ``datetime64`` (:issue:`39221`)
281281
- Bug in :meth:`Timestamp.round`, :meth:`Timestamp.floor`, :meth:`Timestamp.ceil` for values near the implementation bounds of :class:`Timestamp` (:issue:`39244`)
282282
- Bug in :func:`date_range` incorrectly creating :class:`DatetimeIndex` containing ``NaT`` instead of raising ``OutOfBoundsDatetime`` in corner cases (:issue:`24124`)
283-
- Bug in :class:`DataFrame` constructor always copying 2D object arrays
283+
- Bug in :class:`DataFrame` constructor always copying 2D object arrays (:issue:`39272`)
284284

285285
Timedelta
286286
^^^^^^^^^

pandas/core/internals/construction.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ def init_ndarray(values, index, columns, dtype: Optional[DtypeObj], copy: bool):
230230
index, columns = _get_axes(
231231
values.shape[0], values.shape[1], index=index, columns=columns
232232
)
233-
values = values.T
233+
234+
array = values.T
234235

235236
# if we don't have a dtype specified, then try to convert objects
236237
# on the entire block; this is to convert if we have datetimelike's
@@ -248,12 +249,8 @@ def init_ndarray(values, index, columns, dtype: Optional[DtypeObj], copy: bool):
248249
return create_block_manager_from_arrays(
249250
maybe_datetime, columns, [columns, index]
250251
)
251-
else:
252-
array = values
253252
else:
254253
array = maybe_infer_to_datetimelike(values)
255-
else:
256-
array = values
257254

258255
return create_block_manager_from_array(array, [columns, index])
259256

0 commit comments

Comments
 (0)