Skip to content

Commit b8d7b8f

Browse files
committed
Merge pull request #3166 from jreback/GH3163
BUG: GH3163 fixed to_csv with a boundry condition issue at the chunksize break
2 parents 4b65859 + fefdcd8 commit b8d7b8f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

pandas/core/index.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,11 @@ def to_native_types(self, slicer=None, na_rep='', float_format=None):
470470
values = self
471471
if slicer is not None:
472472
values = values[slicer]
473-
mask = isnull(values)
474-
values = np.array(values,dtype=object)
475-
476473
if self.is_all_dates:
477-
return _date_formatter(self)
474+
return _date_formatter(values)
478475
else:
476+
mask = isnull(values)
477+
values = np.array(values,dtype=object)
479478
values[mask] = na_rep
480479

481480
return values.tolist()

pandas/tests/test_frame.py

+16
Original file line numberDiff line numberDiff line change
@@ -4697,6 +4697,22 @@ def test_to_csv_float32_nanrep(self):
46974697
lines = f.readlines()
46984698
self.assert_(lines[1].split(',')[2] == '999')
46994699

4700+
@slow
4701+
def test_to_csv_boundry_conditions(self):
4702+
from pandas.util.testing import makeTimeDataFrame
4703+
4704+
with ensure_clean() as path:
4705+
4706+
df = makeTimeDataFrame(25000)
4707+
df.to_csv(path)
4708+
rs = pan.read_csv(path, index_col=0, parse_dates=True)
4709+
assert_frame_equal(rs, df)
4710+
4711+
df = makeTimeDataFrame(25001)
4712+
df.to_csv(path)
4713+
rs = pan.read_csv(path, index_col=0, parse_dates=True)
4714+
assert_frame_equal(rs, df)
4715+
47004716
def test_to_csv_withcommas(self):
47014717

47024718
# Commas inside fields should be correctly escaped when saving as CSV.

0 commit comments

Comments
 (0)