Skip to content

Commit 1179098

Browse files
committed
Updated EA catch method in _maybe_align_series_as_frame
1 parent dcf3391 commit 1179098

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

pandas/core/frame.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@
123123
notna,
124124
)
125125

126-
from pandas.arrays import (
127-
FloatingArray,
128-
IntegerArray,
129-
)
130126
from pandas.core import (
131127
algorithms,
132128
common as com,
@@ -8447,13 +8443,23 @@ def _maybe_align_series_as_frame(self, series: Series, axis: AxisInt):
84478443
blockwise.
84488444
"""
84498445
rvalues = series._values
8450-
if not isinstance(rvalues, np.ndarray):
8451-
if rvalues.dtype in ("datetime64[ns]", "timedelta64[ns]") or isinstance(
8452-
rvalues, (IntegerArray, FloatingArray)
8453-
):
8454-
rvalues = np.asarray(rvalues)
8446+
if isinstance(rvalues, PeriodArray):
8447+
return series
8448+
if not isinstance(rvalues, (np.ndarray,)) and rvalues.dtype not in (
8449+
"datetime64[ns]",
8450+
"timedelta64[ns]",
8451+
):
8452+
if axis == 0:
8453+
df = DataFrame(dict.fromkeys(range(self.shape[1]), rvalues))
84558454
else:
8456-
return series
8455+
nrows = self.shape[0]
8456+
df = DataFrame(
8457+
{i: rvalues[[i]].repeat(nrows) for i in range(self.shape[1])},
8458+
dtype=rvalues.dtype,
8459+
)
8460+
df.index = self.index
8461+
df.columns = self.columns
8462+
return df
84578463

84588464
if axis == 0:
84598465
rvalues = rvalues.reshape(-1, 1)

0 commit comments

Comments
 (0)