Skip to content

BUG: fixed chunksize guessed to 0 (py3 only). #8621 #8927

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

Merged
merged 1 commit into from
Dec 3, 2014
Merged
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.15.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Bug Fixes
- Bug in ``BlockManager`` where setting values with different type would break block integrity (:issue:`8850`)
- Bug in ``DatetimeIndex`` when using ``time`` object as key (:issue:`8667`)
- Fix negative step support for label-based slices (:issue:`8753`)
- Fixed division by 0 when reading big csv files in python 3 (:issue:`8621`)

Old behavior:

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ def __init__(self, obj, path_or_buf=None, sep=",", na_rep='', float_format=None,
self.data = [None] * ncols

if chunksize is None:
chunksize = (100000 / (len(self.cols) or 1)) or 1
chunksize = (100000 // (len(self.cols) or 1)) or 1
self.chunksize = int(chunksize)

self.data_index = obj.index
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6462,6 +6462,14 @@ def test_to_csv_chunking(self):
rs = read_csv(filename,index_col=0)
assert_frame_equal(rs, aa)

def test_to_csv_wide_frame_formatting(self):
# Issue #8621
df = DataFrame(np.random.randn(1, 100010), columns=None, index=None)
with ensure_clean() as filename:
df.to_csv(filename, header=False, index=False)
rs = read_csv(filename, header=None)
assert_frame_equal(rs, df)

def test_to_csv_bug(self):
f1 = StringIO('a,1.0\nb,2.0')
df = DataFrame.from_csv(f1, header=None)
Expand Down