Skip to content

BUG: GH3163 fixed to_csv with a boundry condition issue at the chunksize break #3166

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
Mar 25, 2013
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
7 changes: 3 additions & 4 deletions pandas/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,11 @@ def to_native_types(self, slicer=None, na_rep='', float_format=None):
values = self
if slicer is not None:
values = values[slicer]
mask = isnull(values)
values = np.array(values,dtype=object)

if self.is_all_dates:
return _date_formatter(self)
return _date_formatter(values)
else:
mask = isnull(values)
values = np.array(values,dtype=object)
values[mask] = na_rep

return values.tolist()
Expand Down
16 changes: 16 additions & 0 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4697,6 +4697,22 @@ def test_to_csv_float32_nanrep(self):
lines = f.readlines()
self.assert_(lines[1].split(',')[2] == '999')

@slow
def test_to_csv_boundry_conditions(self):
from pandas.util.testing import makeTimeDataFrame

with ensure_clean() as path:

df = makeTimeDataFrame(25000)
df.to_csv(path)
rs = pan.read_csv(path, index_col=0, parse_dates=True)
assert_frame_equal(rs, df)

df = makeTimeDataFrame(25001)
df.to_csv(path)
rs = pan.read_csv(path, index_col=0, parse_dates=True)
assert_frame_equal(rs, df)

def test_to_csv_withcommas(self):

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