Skip to content

Commit

Permalink
fixup! BUG: 2D ndarray of dtype 'object' is always copied upon constr…
Browse files Browse the repository at this point in the history
…uction (pandas-dev#39263)
  • Loading branch information
irgolic committed Jan 22, 2021
1 parent d40acbe commit 2649068
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ Datetimelike
- Bug in comparisons between :class:`Timestamp` object and ``datetime64`` objects just outside the implementation bounds for nanosecond ``datetime64`` (:issue:`39221`)
- Bug in :meth:`Timestamp.round`, :meth:`Timestamp.floor`, :meth:`Timestamp.ceil` for values near the implementation bounds of :class:`Timestamp` (:issue:`39244`)
- Bug in :func:`date_range` incorrectly creating :class:`DatetimeIndex` containing ``NaT`` instead of raising ``OutOfBoundsDatetime`` in corner cases (:issue:`24124`)
- Bug in :class:`DataFrame` constructor always copying 2D object arrays
- Bug in :class:`DataFrame` constructor always copying 2D object arrays (:issue:`39272`)

Timedelta
^^^^^^^^^
Expand Down
7 changes: 2 additions & 5 deletions pandas/core/internals/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ def init_ndarray(values, index, columns, dtype: Optional[DtypeObj], copy: bool):
index, columns = _get_axes(
values.shape[0], values.shape[1], index=index, columns=columns
)
values = values.T

array = values.T

# if we don't have a dtype specified, then try to convert objects
# on the entire block; this is to convert if we have datetimelike's
Expand All @@ -248,12 +249,8 @@ def init_ndarray(values, index, columns, dtype: Optional[DtypeObj], copy: bool):
return create_block_manager_from_arrays(
maybe_datetime, columns, [columns, index]
)
else:
array = values
else:
array = maybe_infer_to_datetimelike(values)
else:
array = values

return create_block_manager_from_array(array, [columns, index])

Expand Down

0 comments on commit 2649068

Please sign in to comment.