Skip to content

Commit dcf3391

Browse files
committed
Limit np conversion to IntegerArray and FloatArray
1 parent a5940d5 commit dcf3391

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
@@ -123,6 +123,10 @@
123123
notna,
124124
)
125125

126+
from pandas.arrays import (
127+
FloatingArray,
128+
IntegerArray,
129+
)
126130
from pandas.core import (
127131
algorithms,
128132
common as com,
@@ -8444,7 +8448,12 @@ def _maybe_align_series_as_frame(self, series: Series, axis: AxisInt):
84448448
"""
84458449
rvalues = series._values
84468450
if not isinstance(rvalues, np.ndarray):
8447-
rvalues = np.asarray(rvalues)
8451+
if rvalues.dtype in ("datetime64[ns]", "timedelta64[ns]") or isinstance(
8452+
rvalues, (IntegerArray, FloatingArray)
8453+
):
8454+
rvalues = np.asarray(rvalues)
8455+
else:
8456+
return series
84488457

84498458
if axis == 0:
84508459
rvalues = rvalues.reshape(-1, 1)

0 commit comments

Comments
 (0)