Skip to content

Commit a230b57

Browse files
committed
Limit np conversion to IntegerArray and FloatArray
1 parent 51b0898 commit a230b57

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pandas/core/frame.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@
125125
notna,
126126
)
127127

128+
from pandas.arrays import (
129+
FloatingArray,
130+
IntegerArray,
131+
)
128132
from pandas.core import (
129133
algorithms,
130134
common as com,
@@ -8469,7 +8473,12 @@ def _maybe_align_series_as_frame(self, series: Series, axis: AxisInt):
84698473
"""
84708474
rvalues = series._values
84718475
if not isinstance(rvalues, np.ndarray):
8472-
rvalues = np.asarray(rvalues)
8476+
if rvalues.dtype in ("datetime64[ns]", "timedelta64[ns]") or isinstance(
8477+
rvalues, (IntegerArray, FloatingArray)
8478+
):
8479+
rvalues = np.asarray(rvalues)
8480+
else:
8481+
return series
84738482

84748483
if axis == 0:
84758484
rvalues = rvalues.reshape(-1, 1)

0 commit comments

Comments
 (0)