Skip to content

Commit 549422f

Browse files
committed
BUG: fixed chunksize guessed to 0 (py3 only). pandas-dev#8621
1 parent e2f8f0a commit 549422f

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

doc/source/whatsnew/v0.15.2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Bug Fixes
9999
- Bug in ``BlockManager`` where setting values with different type would break block integrity (:issue:`8850`)
100100
- Bug in ``DatetimeIndex`` when using ``time`` object as key (:issue:`8667`)
101101
- Fix negative step support for label-based slices (:issue:`8753`)
102+
- Fixed division by 0 when reading big csv files in python 3 (:issue:`8621`)
102103

103104
Old behavior:
104105

pandas/core/format.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ def __init__(self, obj, path_or_buf=None, sep=",", na_rep='', float_format=None,
12471247
self.data = [None] * ncols
12481248

12491249
if chunksize is None:
1250-
chunksize = (100000 / (len(self.cols) or 1)) or 1
1250+
chunksize = (100000 // (len(self.cols) or 1)) or 1
12511251
self.chunksize = int(chunksize)
12521252

12531253
self.data_index = obj.index

pandas/tests/test_frame.py

+8
Original file line numberDiff line numberDiff line change
@@ -6462,6 +6462,14 @@ def test_to_csv_chunking(self):
64626462
rs = read_csv(filename,index_col=0)
64636463
assert_frame_equal(rs, aa)
64646464

6465+
def test_to_csv_wide_frame_formatting(self):
6466+
# Issue #8621
6467+
df = DataFrame(np.random.randn(1, 100010), columns=None, index=None)
6468+
with ensure_clean() as filename:
6469+
df.to_csv(filename, header=False, index=False)
6470+
rs = read_csv(filename, header=None)
6471+
assert_frame_equal(rs, df)
6472+
64656473
def test_to_csv_bug(self):
64666474
f1 = StringIO('a,1.0\nb,2.0')
64676475
df = DataFrame.from_csv(f1, header=None)

0 commit comments

Comments
 (0)