Skip to content

Commit 050e8b5

Browse files
committed
CLN: applied gfyoung's feedback
1 parent 415e733 commit 050e8b5

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

doc/source/whatsnew/v0.24.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ MultiIndex
147147
I/O
148148
^^^
149149

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`)
151151
-
152152
-
153153

pandas/tests/io/formats/test_to_csv.py

+20-16
Original file line numberDiff line numberDiff line change
@@ -295,22 +295,24 @@ def test_to_csv_string_with_lf(self):
295295
df = pd.DataFrame(data)
296296

297297
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\nef"\n' \
298+
expected_bin = (
299+
b'int,str_lf\n'
300+
b'1,abc\n'
301+
b'2,"d\nef"\n'
302302
b'3,"g\nh\n\ni"\n'
303+
)
303304

304305
df.to_csv(path, index=False)
305306
with open(path, 'rb') as f:
306307
assert f.read() == expected_bin
307308

308309
# '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\nef"\r\n' \
310+
expected_bin =(
311+
b'int,str_lf\r\n'
312+
b'1,abc\r\n'
313+
b'2,"d\nef"\r\n'
313314
b'3,"g\nh\n\ni"\r\n'
315+
)
314316

315317
df.to_csv(path, line_terminator='\r\n', index=False)
316318
with open(path, 'rb') as f:
@@ -325,21 +327,23 @@ def test_to_csv_string_with_crlf(self):
325327
df = pd.DataFrame(data)
326328

327329
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\nef"\n' \
330+
expected_bin = (
331+
b'int,str_crlf\n'
332+
b'1,abc\n'
333+
b'2,"d\r\nef"\n'
332334
b'3,"g\r\nh\r\n\r\ni"\n'
335+
)
333336

334337
df.to_csv(path, index=False)
335338
with open(path, 'rb') as f:
336339
assert f.read() == expected_bin
337340

338-
expected_bin = \
339-
b'int,str_crlf\r\n' \
340-
b'1,abc\r\n' \
341-
b'2,"d\r\nef"\r\n' \
341+
expected_bin = (
342+
b'int,str_crlf\r\n'
343+
b'1,abc\r\n'
344+
b'2,"d\r\nef"\r\n'
342345
b'3,"g\r\nh\r\n\r\ni"\r\n'
346+
)
343347

344348
df.to_csv(path, line_terminator='\r\n', index=False)
345349
with open(path, 'rb') as f:

0 commit comments

Comments
 (0)