Skip to content

Commit 383694c

Browse files
author
Marco Gorelli
committed
👌 use other._values instead of other.values and .to_frame().T
1 parent f87f987 commit 383694c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pandas/core/frame.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -6758,17 +6758,19 @@ def append(self, other, ignore_index=False, verify_integrity=False, sort=False):
67586758
)
67596759

67606760
index = Index([other.name], name=self.index.name)
6761+
67616762
idx_diff = other.index.difference(self.columns)
67626763
try:
67636764
combined_columns = self.columns.append(idx_diff)
67646765
except TypeError:
67656766
combined_columns = self.columns.astype(object).append(idx_diff)
6766-
other = (
6767-
other.reindex(combined_columns, copy=False)
6768-
.to_frame()
6769-
.T.infer_objects()
6770-
.rename_axis(index.names)
6767+
other = other.reindex(combined_columns, copy=False)
6768+
other = DataFrame(
6769+
other._values.reshape((1, len(other))),
6770+
index=index,
6771+
columns=combined_columns,
67716772
)
6773+
other = other.infer_objects()
67726774
if not self.columns.equals(combined_columns):
67736775
self = self.reindex(columns=combined_columns)
67746776
elif isinstance(other, list):

0 commit comments

Comments
 (0)