Skip to content

0.24.0 breaks records oriented to_dict with non-natural naming #25023

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
jmavila opened this issue Jan 30, 2019 · 1 comment
Closed

0.24.0 breaks records oriented to_dict with non-natural naming #25023

jmavila opened this issue Jan 30, 2019 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request

Comments

@jmavila
Copy link

jmavila commented Jan 30, 2019

Code Sample, a copy-pastable example if possible

import pandas as pd
pd.DataFrame([{'a-1': 34087, 'b': 'blablabla', 'c': 55}]).to_dict(orient='records')  # Out: [{'_0': 34087, 'b': 'blablabla', 'c': 55}]

Problem description

The behaviour of to_dict(orient='records') has changed in version 0.24. In all previous versions the result of the above test is:

 [{'a-1': 34087, 'b': 'blablabla', 'c': 55}]

but the current result is:

 [{'_0': 34087, 'b': 'blablabla', 'c': 55}]

The keys with hyphens are renamed to "_" + number.

Expected Output

The same as in the previous versions of Pandas:

 [{'a-1': 34087, 'b': 'blablabla', 'c': 55}]

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-36-lowlatency
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None

pandas: 0.24.0
pytest: 4.0.2
pip: 18.1
setuptools: 40.7.1
Cython: 0.29.3
numpy: 1.16.0
scipy: 0.18.1
pyarrow: None
xarray: None
IPython: 5.8.0
sphinx: None
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.7
blosc: 1.5.1
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.9
feather: None
matplotlib: 2.2.2
openpyxl: 2.5.12
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.2
lxml.etree: 4.2.5
bs4: 4.5.3
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

@TomAugspurger
Copy link
Contributor

This is fixed in master. We'll be releasing 0.24.1 in the next couple days with a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants