File tree 2 files changed +21
-17
lines changed
2 files changed +21
-17
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ MultiIndex
147
147
I/O
148
148
^^^
149
149
150
- - (Only for Windows) Bug in :meth:`DataFrame.to_csv`, in which all `\n`s are converted to `\r\n` (:issue:`20353`)
150
+ - Bug in :meth:`DataFrame.to_csv`, in which all `\n`s are converted to `\r\n` on Windows (:issue:`20353`)
151
151
-
152
152
-
153
153
Original file line number Diff line number Diff line change @@ -295,22 +295,24 @@ def test_to_csv_string_with_lf(self):
295
295
df = pd .DataFrame (data )
296
296
297
297
with tm .ensure_clean ('lf_test.csv' ) as path :
298
- expected_bin = \
299
- b'int,str_lf\n ' \
300
- b'1,abc\n ' \
301
- b'2,"d\n ef"\n ' \
298
+ expected_bin = (
299
+ b'int,str_lf\n '
300
+ b'1,abc\n '
301
+ b'2,"d\n ef"\n '
302
302
b'3,"g\n h\n \n i"\n '
303
+ )
303
304
304
305
df .to_csv (path , index = False )
305
306
with open (path , 'rb' ) as f :
306
307
assert f .read () == expected_bin
307
308
308
309
# 'line_terminator' should not change inner element
309
- expected_bin = \
310
- b'int,str_lf\r \n ' \
311
- b'1,abc\r \n ' \
312
- b'2,"d\n ef"\r \n ' \
310
+ expected_bin = (
311
+ b'int,str_lf\r \n '
312
+ b'1,abc\r \n '
313
+ b'2,"d\n ef"\r \n '
313
314
b'3,"g\n h\n \n i"\r \n '
315
+ )
314
316
315
317
df .to_csv (path , line_terminator = '\r \n ' , index = False )
316
318
with open (path , 'rb' ) as f :
@@ -325,21 +327,23 @@ def test_to_csv_string_with_crlf(self):
325
327
df = pd .DataFrame (data )
326
328
327
329
with tm .ensure_clean ('crlf_test.csv' ) as path :
328
- expected_bin = \
329
- b'int,str_crlf\n ' \
330
- b'1,abc\n ' \
331
- b'2,"d\r \n ef"\n ' \
330
+ expected_bin = (
331
+ b'int,str_crlf\n '
332
+ b'1,abc\n '
333
+ b'2,"d\r \n ef"\n '
332
334
b'3,"g\r \n h\r \n \r \n i"\n '
335
+ )
333
336
334
337
df .to_csv (path , index = False )
335
338
with open (path , 'rb' ) as f :
336
339
assert f .read () == expected_bin
337
340
338
- expected_bin = \
339
- b'int,str_crlf\r \n ' \
340
- b'1,abc\r \n ' \
341
- b'2,"d\r \n ef"\r \n ' \
341
+ expected_bin = (
342
+ b'int,str_crlf\r \n '
343
+ b'1,abc\r \n '
344
+ b'2,"d\r \n ef"\r \n '
342
345
b'3,"g\r \n h\r \n \r \n i"\r \n '
346
+ )
343
347
344
348
df .to_csv (path , line_terminator = '\r \n ' , index = False )
345
349
with open (path , 'rb' ) as f :
You can’t perform that action at this time.
0 commit comments