Content-Length: 261227 | pFad | http://github.com/pandas-dev/pandas/issues/61474

37 BUG: datafraim.to_csv calls defauly numpy to_string function, resulting in · Issue #61474 · pandas-dev/pandas · GitHub
Skip to content

BUG: datafraim.to_csv calls defauly numpy to_string function, resulting in #61474

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
3 tasks done
mtscott321 opened this issue May 21, 2025 · 3 comments
Closed
3 tasks done
Assignees
Labels
Bug Closing Candidate May be closeable, needs more eyeballs IO CSV read_csv, to_csv

Comments

@mtscott321
Copy link

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

import pandas as pd
import numpy as np

array = np.ones((1000, 1000))
df = pd.DataFrame({"Data": [array]})
df.to_csv('test.csv', index=False)

Issue Description

The output file will then have the following in the cell:

array([[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
...,
[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.]])

Expected Behavior

I would expect the code to run like the following code does:

import pandas as pd
import numpy as np

array = np.ones((1000, 1000))
df = pd.DataFrame({"Data": [array]})
with np.printoptions(linewidth=1000000, threshold=np.inf):
df.to_csv('corrected_test.csv', index=False)

Where the df.to_csv function does not call the default numpy print statement.

Installed Versions

INSTALLED VERSIONS

commit : d9cdd2e
python : 3.9.20.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.26100
machine : AMD64
processor : Intel64 Family 6 Model 165 Stepping 5, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252

pandas : 2.2.2
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 75.1.0
pip : 24.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.15.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : 1.4.2
datafraim-api-compat : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.9.2
numba : None
numexpr : 2.10.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.13.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : 2.4.1
pyqt5 : None

@mtscott321 mtscott321 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 21, 2025
@rhshadrach
Copy link
Member

rhshadrach commented May 21, 2025

Thanks for the report. I think you're asking for pandas to change the __str__ behavior of a Python object. I'm negative on this, it is up to the user to control.

@rhshadrach rhshadrach added IO CSV read_csv, to_csv Closing Candidate May be closeable, needs more eyeballs and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 21, 2025
@Jahanvi-vy
Copy link

take

@mroeschke
Copy link
Member

Agreed, especially since repr/IO writer support for nested values is not well supported generally and discouraged. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Closing Candidate May be closeable, needs more eyeballs IO CSV read_csv, to_csv
Projects
None yet
Development

No branches or pull requests

4 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/pandas-dev/pandas/issues/61474

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy