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

regression in 0.24: to_dict sometimes loses column names #25078

Closed
sam-s opened this issue Feb 1, 2019 · 1 comment
Closed

regression in 0.24: to_dict sometimes loses column names #25078

sam-s opened this issue Feb 1, 2019 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request

Comments

@sam-s
Copy link

sam-s commented Feb 1, 2019

Code Sample

import pandas as pd
pd.DataFrame([[1,2,3],[4,5,6],[7,8,9]],columns=["a?","b!","c"]).to_dict(orient="records")

Problem description

Column names with non-alphanumeric characters are replaced with "_n" in 0.24.0:

[{'_0': 1, '_1': 2, 'c': 3}, {'_0': 4, '_1': 5, 'c': 6}, {'_0': 7, '_1': 8, 'c': 9}]

Expected Output

In 0.23.4:

[{'a?': 1, 'b!': 2, 'c': 3}, {'a?': 4, 'b!': 5, 'c': 6}, {'a?': 7, 'b!': 8, 'c': 9}]

Output of pd.show_versions()

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

pandas: 0.24.0
pytest: None
pip: 19.0.1
setuptools: 40.7.0
Cython: None
numpy: 1.16.0
scipy: 1.2.0
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: 3.0.2
openpyxl: None
xlrd: 1.2.0
xlwt: None
xlsxwriter: 1.1.2
lxml.etree: 4.3.0
bs4: None
html5lib: None
sqlalchemy: 1.2.17
pymysql: None
psycopg2: 2.7.7 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

@WillAyd
Copy link
Member

WillAyd commented Feb 1, 2019

Duplicate of #24940 fix will come out in 0.24.1

@WillAyd WillAyd closed this as completed Feb 1, 2019
@WillAyd WillAyd added the Duplicate Report Duplicate issue or pull request label Feb 1, 2019
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