Skip to content

Commit 1bce70f

Browse files
author
Chris Bertinato
committed
BUG: Replace internal use of loc with reindex in append
1 parent 6c613c8 commit 1bce70f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

doc/source/whatsnew/v0.25.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ Indexing
325325
^^^^^^^^
326326

327327
- Improved exception message when calling :meth:`DataFrame.iloc` with a list of non-numeric objects (:issue:`25753`).
328-
-
328+
- Bug in which :meth:`DataFrame.append` produced a warning indicating that a KeyError will be thrown in the future when the data to be appended contains new columns (:issue:`22252`).
329329
-
330330

331331

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6731,7 +6731,7 @@ def append(self, other, ignore_index=False,
67316731
elif isinstance(other, list) and not isinstance(other[0], DataFrame):
67326732
other = DataFrame(other)
67336733
if (self.columns.get_indexer(other.columns) >= 0).all():
6734-
other = other.loc[:, self.columns]
6734+
other = other.reindex(columns=self.columns)
67356735

67366736
from pandas.core.reshape.concat import concat
67376737
if isinstance(other, (list, tuple)):

0 commit comments

Comments
 (0)