-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
Description
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()
Details
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-8pandas: 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