Skip to content

Commit 2a1853d

Browse files
committed
CLN: Removed the kwds param in to_csv
Closes gh-8206. [ci skip]
1 parent 2c55f28 commit 2a1853d

File tree

5 files changed

+6
-34
lines changed

5 files changed

+6
-34
lines changed

doc/source/whatsnew/v0.19.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ Removal of prior version deprecations/changes
693693
- ``DataFrame.to_sql()`` has dropped the ``mysql`` option for the ``flavor`` parameter (:issue:`13611`)
694694
- ``pd.Index`` has dropped the ``diff`` method in favour of ``difference`` (:issue:`13669`)
695695

696+
- ``Series.to_csv`` has dropped the ``nanRep`` parameter in favor of ``na_rep`` (:issue:`13804`)
696697
- ``Series.xs``, ``DataFrame.xs``, ``Panel.xs``, ``Panel.major_xs``, and ``Panel.minor_xs`` have dropped the ``copy`` parameter (:issue:`13781`)
697698
- ``str.split`` has dropped the ``return_type`` parameter in favor of ``expand`` (:issue:`13701`)
698699
- Removal of the legacy time rules (offset aliases), deprecated since 0.17.0 (this has been alias since 0.8.0) (:issue:`13590`)

pandas/core/frame.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
13051305
mode='w', encoding=None, compression=None, quoting=None,
13061306
quotechar='"', line_terminator='\n', chunksize=None,
13071307
tupleize_cols=False, date_format=None, doublequote=True,
1308-
escapechar=None, decimal='.', **kwds):
1308+
escapechar=None, decimal='.'):
13091309
r"""Write DataFrame to a comma-separated values (csv) file
13101310
13111311
Parameters
@@ -1332,8 +1332,6 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
13321332
sequence should be given if the DataFrame uses MultiIndex. If
13331333
False do not print fields for index names. Use index_label=False
13341334
for easier importing in R
1335-
nanRep : None
1336-
deprecated, use na_rep
13371335
mode : str
13381336
Python write mode, default 'w'
13391337
encoding : string, optional

pandas/core/series.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2534,8 +2534,8 @@ def from_csv(cls, path, sep=',', parse_dates=True, header=None,
25342534
return result
25352535

25362536
def to_csv(self, path, index=True, sep=",", na_rep='', float_format=None,
2537-
header=False, index_label=None, mode='w', nanRep=None,
2538-
encoding=None, date_format=None, decimal='.'):
2537+
header=False, index_label=None, mode='w', encoding=None,
2538+
date_format=None, decimal='.'):
25392539
"""
25402540
Write Series to a comma-separated values (csv) file
25412541
@@ -2572,7 +2572,7 @@ def to_csv(self, path, index=True, sep=",", na_rep='', float_format=None,
25722572
# result is only a string if no path provided, otherwise None
25732573
result = df.to_csv(path, index=index, sep=sep, na_rep=na_rep,
25742574
float_format=float_format, header=header,
2575-
index_label=index_label, mode=mode, nanRep=nanRep,
2575+
index_label=index_label, mode=mode,
25762576
encoding=encoding, date_format=date_format,
25772577
decimal=decimal)
25782578
if path is None:

pandas/tests/formats/test_format.py

-27
Original file line numberDiff line numberDiff line change
@@ -3139,10 +3139,6 @@ def test_to_csv_quotechar(self):
31393139
df.to_csv(path, quoting=1) # 1=QUOTE_ALL
31403140
with open(path, 'r') as f:
31413141
self.assertEqual(f.read(), expected)
3142-
with tm.ensure_clean('test.csv') as path:
3143-
df.to_csv(path, quoting=1, engine='python')
3144-
with open(path, 'r') as f:
3145-
self.assertEqual(f.read(), expected)
31463142

31473143
expected = """\
31483144
$$,$col$
@@ -3154,17 +3150,10 @@ def test_to_csv_quotechar(self):
31543150
df.to_csv(path, quoting=1, quotechar="$")
31553151
with open(path, 'r') as f:
31563152
self.assertEqual(f.read(), expected)
3157-
with tm.ensure_clean('test.csv') as path:
3158-
df.to_csv(path, quoting=1, quotechar="$", engine='python')
3159-
with open(path, 'r') as f:
3160-
self.assertEqual(f.read(), expected)
31613153

31623154
with tm.ensure_clean('test.csv') as path:
31633155
with tm.assertRaisesRegexp(TypeError, 'quotechar'):
31643156
df.to_csv(path, quoting=1, quotechar=None)
3165-
with tm.ensure_clean('test.csv') as path:
3166-
with tm.assertRaisesRegexp(TypeError, 'quotechar'):
3167-
df.to_csv(path, quoting=1, quotechar=None, engine='python')
31683157

31693158
def test_to_csv_doublequote(self):
31703159
df = DataFrame({'col': ['a"a', '"bb"']})
@@ -3178,18 +3167,11 @@ def test_to_csv_doublequote(self):
31783167
df.to_csv(path, quoting=1, doublequote=True) # QUOTE_ALL
31793168
with open(path, 'r') as f:
31803169
self.assertEqual(f.read(), expected)
3181-
with tm.ensure_clean('test.csv') as path:
3182-
df.to_csv(path, quoting=1, doublequote=True, engine='python')
3183-
with open(path, 'r') as f:
3184-
self.assertEqual(f.read(), expected)
31853170

31863171
from _csv import Error
31873172
with tm.ensure_clean('test.csv') as path:
31883173
with tm.assertRaisesRegexp(Error, 'escapechar'):
31893174
df.to_csv(path, doublequote=False) # no escapechar set
3190-
with tm.ensure_clean('test.csv') as path:
3191-
with tm.assertRaisesRegexp(Error, 'escapechar'):
3192-
df.to_csv(path, doublequote=False, engine='python')
31933175

31943176
def test_to_csv_escapechar(self):
31953177
df = DataFrame({'col': ['a"a', '"bb"']})
@@ -3203,11 +3185,6 @@ def test_to_csv_escapechar(self):
32033185
df.to_csv(path, quoting=1, doublequote=False, escapechar='\\')
32043186
with open(path, 'r') as f:
32053187
self.assertEqual(f.read(), expected)
3206-
with tm.ensure_clean('test.csv') as path:
3207-
df.to_csv(path, quoting=1, doublequote=False, escapechar='\\',
3208-
engine='python')
3209-
with open(path, 'r') as f:
3210-
self.assertEqual(f.read(), expected)
32113188

32123189
df = DataFrame({'col': ['a,a', ',bb,']})
32133190
expected = """\
@@ -3220,10 +3197,6 @@ def test_to_csv_escapechar(self):
32203197
df.to_csv(path, quoting=3, escapechar='\\') # QUOTE_NONE
32213198
with open(path, 'r') as f:
32223199
self.assertEqual(f.read(), expected)
3223-
with tm.ensure_clean('test.csv') as path:
3224-
df.to_csv(path, quoting=3, escapechar='\\', engine='python')
3225-
with open(path, 'r') as f:
3226-
self.assertEqual(f.read(), expected)
32273200

32283201
def test_csv_to_string(self):
32293202
df = DataFrame({'col': [1, 2]})

pandas/tests/frame/test_to_csv.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ def test_to_csv_path_is_none(self):
896896
# GH 8215
897897
# Make sure we return string for consistency with
898898
# Series.to_csv()
899-
csv_str = self.frame.to_csv(path=None)
899+
csv_str = self.frame.to_csv(path_or_buf=None)
900900
self.assertIsInstance(csv_str, str)
901901
recons = pd.read_csv(StringIO(csv_str), index_col=0)
902902
assert_frame_equal(self.frame, recons)

0 commit comments

Comments
 (0)