Skip to content
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

0.24.0 Regression in DataFrame.to_dict(orient='records') with whitespace column headers #24991

Closed
omni-vi opened this issue Jan 29, 2019 · 1 comment

Comments

@omni-vi
Copy link

omni-vi commented Jan 29, 2019

Code Sample, a copy-pastable example if possible

import pandas as pd
df2 = pd.DataFrame({'a': [1], 'a b': [2]})
df2.to_dict(orient="records")

Problem description

If a dataframe header contains two fields that start with the same substring, followed by whitespace, the header is not used as dict-key.

An example explains it best:

The expected output (works with 0.23.4) is

[{'a': 1, 'a b': 2}]

The actual output with 0.24.0 is

[{'a': 1, '_1': 2}]

Notice, that the second key is now _1 and not a b as expected

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.7.2.final.0 python-bits: 64 OS: Darwin OS-release: 18.2.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: de_DE.UTF-8 LOCALE: de_DE.UTF-8

pandas: 0.24.0
pytest: None
pip: 19.0.1
setuptools: 40.6.3
Cython: None
numpy: 1.16.0
scipy: None
pyarrow: None
xarray: None
IPython: 7.2.0
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

@TomAugspurger
Copy link
Contributor

Based off the title, I'm guessing this was fixed by #24965. Will be doing a release with that soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants