Skip to content

DataFrame.append() does not create missing columns #6129

Closed
@brandjon

Description

@brandjon

Appending a Series to a DataFrame does not create new columns in the DataFrame for unmatched labels in the Series.

df = pd.DataFrame({'a': {'x': 1, 'y': 2}, 'b': {'x': 3, 'y': 4}})
row = pd.Series([5, 6, 7], index=['a', 'b', 'c'], name='z')

df = df.append(row)
print(df.to_string())

Result:

   a  b
x  1  3
y  2  4
z  5  6

This behavior is contrary to the documentation for append().

INSTALLED VERSIONS

Python: 3.3.0.final.0
OS: Windows
Release: 7
Processor: x86 Family 6 Model 37 Stepping 5, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.13.0
Cython: Not installed
Numpy: 1.7.0rc1
Scipy: Not installed
statsmodels: Not installed
patsy: Not installed
scikits.timeseries: Not installed
dateutil: 2.2
pytz: 2013.9
bottleneck: Not installed
PyTables: Not Installed
numexpr: Not Installed
matplotlib: 1.3.0
openpyxl: Not installed
xlrd: Not installed
xlwt: Not installed
xlsxwriter: Not installed
sqlalchemy: Not installed
lxml: Not installed
bs4: Not installed
html5lib: Not installed
bigquery: Not installed
apiclient: Not installed

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions