Skip to content

Speed up a test #46547

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
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pandas/io/formats/csvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
from pandas.io.formats.format import DataFrameFormatter


_DEFAULT_CHUNKSIZE_CELLS = 100_000


class CSVFormatter:
cols: np.ndarray

Expand Down Expand Up @@ -162,7 +165,7 @@ def _initialize_columns(self, cols: Sequence[Hashable] | None) -> np.ndarray:

def _initialize_chunksize(self, chunksize: int | None) -> int:
if chunksize is None:
return (100000 // (len(self.cols) or 1)) or 1
return (_DEFAULT_CHUNKSIZE_CELLS // (len(self.cols) or 1)) or 1
return int(chunksize)

@property
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/frame/methods/test_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,9 +759,11 @@ def test_to_csv_chunking(self, chunksize):
tm.assert_frame_equal(rs, aa)

@pytest.mark.slow
def test_to_csv_wide_frame_formatting(self):
def test_to_csv_wide_frame_formatting(self, monkeypatch):
Copy link
Contributor

@jreback jreback Mar 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a specific regression test #8621

i dont' think changing this is actually helping. (sure it helps in the running of the test but breaks the regression checking).

# Issue #8621
df = DataFrame(np.random.randn(1, 100010), columns=None, index=None)
n_cells = 1_000
monkeypatch.setattr("pandas.io.formats.csvs._DEFAULT_CHUNKSIZE_CELLS", n_cells)
df = DataFrame(np.random.randn(1, n_cells + 10), columns=None, index=None)
with tm.ensure_clean() as filename:
df.to_csv(filename, header=False, index=False)
rs = read_csv(filename, header=None)
Expand Down