Skip to content

Commit fa775bd

Browse files
committed
use is_homogeneous_type
1 parent 8e2bbee commit fa775bd

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pandas/core/generic.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -727,12 +727,11 @@ def transpose(self, *args, **kwargs):
727727
nv.validate_transpose(tuple(), kwargs)
728728
result = self._constructor(new_values, **new_axes).__finalize__(self)
729729

730-
if len(self.columns) and (self.dtypes == self.dtypes.iloc[0]).all():
731-
# FIXME: self.dtypes[0] can fail in tests
730+
if self.ndim == 2 and self._is_homogeneous_type and len(self.columns):
732731
if is_extension_array_dtype(self.dtypes.iloc[0]):
733732
# Retain ExtensionArray dtypes through transpose;
734733
# TODO: this can be made cleaner if/when (N, 1) EA are allowed
735-
dtype = self.dtypes[0]
734+
dtype = self.dtypes.iloc[0]
736735
for col in result.columns:
737736
result[col] = result[col].astype(dtype)
738737

0 commit comments

Comments
 (0)