Skip to content

Commit 648bf4d

Browse files
committed
Simplify CSVFormatter.save
1 parent 3ccfb00 commit 648bf4d

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pandas/io/formats/csvs.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,9 @@ def __init__(self, obj, path_or_buf=None, sep=",", na_rep='',
125125

126126
def save(self):
127127
# create the writer & save
128-
if self.encoding is None:
129-
if compat.PY2:
130-
encoding = 'ascii'
131-
else:
132-
encoding = 'utf-8'
133-
else:
134-
encoding = self.encoding
128+
encoding = self.encoding
129+
if encoding is None:
130+
encoding = 'ascii' if compat.compat.PY2 else 'utf-8'
135131

136132
# GH 21227 internal compression is not used when file-like passed.
137133
if self.compression and hasattr(self.path_or_buf, 'write'):

0 commit comments

Comments
 (0)