-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: to_dict("index") and to_dict("list") don't coerce to native types #46751
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
Comments
Thanks @RogerThomas for the report. note there is an open issue #25969 related to this and also Series.items(). I will label as a duplicate but keep this one open for now since it is not immediately apparent what is outstanding to close #25969 and this issue is at least explicit on the |
Thanks @simonjayhawkins, sorry I didn't see that issue. I would imagine my PR would fix that issue |
There maybe other issues (excluding the EA ones) related to this that it maybe worth checking if your PR fixes https://github.com/pandas-dev/pandas/search?q=to_dict+native+python&state=open&type=issues |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
When using to_dict ONLY for orient=list/index the values are not coerced to python native types. We are simply missing a
maybe_box_native
callExpected Behavior
Each value in the resulting
to_dict
output should be Python native types, instead we are getting int64's and float64's.This ONLY happens for orient=list and orient=index, the other orients correctly coerce to native types.
Installed Versions
pandas : 1.4.2
numpy : 1.22.1
pytz : 2021.1
dateutil : 2.8.1
pip : 22.0.3
setuptools : 57.0.0
Cython : 0.29.23
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.3.7
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.9.1
jinja2 : 3.0.1
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : 0.6.2
gcsfs : None
markupsafe : 2.0.1
matplotlib : 3.4.2
numba : 0.53.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 4.0.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.6.3
snappy : None
sqlalchemy : 1.1.12
tables : None
tabulate : None
xarray : None
xlrd : 1.1.0
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: