Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brandjon opened this issue Jan 27, 2014 · 1 comment · Fixed by #6130
Closed

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

brandjon opened this issue Jan 27, 2014 · 1 comment · Fixed by #6130
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@brandjon
Copy link

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

@jreback
Copy link
Contributor

jreback commented Jan 27, 2014

thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants