Skip to content

Dtype inconsistency when appending to empty dataframe #22621

@jonathanrocher

Description

@jonathanrocher

Code Sample, a copy-pastable example if possible

>>> pd.DataFrame().append({"a": 1}, ignore_index=True) a 0 1.0

Problem description

I would expect append not to change the dtype of the a column from int to float, and for the output to be identical to that of pd.concat([pd.DataFrame(), pd.DataFrame([{"a": 1}])])

Expected Output

>>> pd.DataFrame().append({"a": 1}, ignore_index=True) a 0 1

Output of pd.show_versions()

INSTALLED VERSIONS

commit: 4612312
python: 2.7.13.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None

pandas: 0.24.0.dev0+547.g4612312
pytest: None
pip: 18.0
setuptools: 34.3.3
Cython: 0.25.2
numpy: 1.13.3
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 5.3.0
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsReshapingConcat, Merge/Join, Stack/Unstack, ExplodeVoid Dtypedtype for no-data cases

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions