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()
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