Skip to content

CLN: Removed the kwds param in to_csv #13804

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
Jul 29, 2016
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.19.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ Removal of prior version deprecations/changes
- ``DataFrame.to_sql()`` has dropped the ``mysql`` option for the ``flavor`` parameter (:issue:`13611`)
- ``pd.Index`` has dropped the ``diff`` method in favour of ``difference`` (:issue:`13669`)

- ``Series.to_csv`` has dropped the ``nanRep`` parameter in favor of ``na_rep`` (:issue:`13804`)
- ``Series.xs``, ``DataFrame.xs``, ``Panel.xs``, ``Panel.major_xs``, and ``Panel.minor_xs`` have dropped the ``copy`` parameter (:issue:`13781`)
- ``str.split`` has dropped the ``return_type`` parameter in favor of ``expand`` (:issue:`13701`)
- Removal of the legacy time rules (offset aliases), deprecated since 0.17.0 (this has been alias since 0.8.0) (:issue:`13590`)
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
mode='w', encoding=None, compression=None, quoting=None,
quotechar='"', line_terminator='\n', chunksize=None,
tupleize_cols=False, date_format=None, doublequote=True,
escapechar=None, decimal='.', **kwds):
escapechar=None, decimal='.'):
r"""Write DataFrame to a comma-separated values (csv) file

Parameters
Expand All @@ -1332,8 +1332,6 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
sequence should be given if the DataFrame uses MultiIndex. If
False do not print fields for index names. Use index_label=False
for easier importing in R
nanRep : None
deprecated, use na_rep
mode : str
Python write mode, default 'w'
encoding : string, optional
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2534,8 +2534,8 @@ def from_csv(cls, path, sep=',', parse_dates=True, header=None,
return result

def to_csv(self, path, index=True, sep=",", na_rep='', float_format=None,
header=False, index_label=None, mode='w', nanRep=None,
encoding=None, date_format=None, decimal='.'):
header=False, index_label=None, mode='w', encoding=None,
date_format=None, decimal='.'):
"""
Write Series to a comma-separated values (csv) file

Expand Down Expand Up @@ -2572,7 +2572,7 @@ def to_csv(self, path, index=True, sep=",", na_rep='', float_format=None,
# result is only a string if no path provided, otherwise None
result = df.to_csv(path, index=index, sep=sep, na_rep=na_rep,
float_format=float_format, header=header,
index_label=index_label, mode=mode, nanRep=nanRep,
index_label=index_label, mode=mode,
encoding=encoding, date_format=date_format,
decimal=decimal)
if path is None:
Expand Down
27 changes: 0 additions & 27 deletions pandas/tests/formats/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -3139,10 +3139,6 @@ def test_to_csv_quotechar(self):
df.to_csv(path, quoting=1) # 1=QUOTE_ALL
with open(path, 'r') as f:
self.assertEqual(f.read(), expected)
with tm.ensure_clean('test.csv') as path:
df.to_csv(path, quoting=1, engine='python')
with open(path, 'r') as f:
self.assertEqual(f.read(), expected)

expected = """\
$$,$col$
Expand All @@ -3154,17 +3150,10 @@ def test_to_csv_quotechar(self):
df.to_csv(path, quoting=1, quotechar="$")
with open(path, 'r') as f:
self.assertEqual(f.read(), expected)
with tm.ensure_clean('test.csv') as path:
df.to_csv(path, quoting=1, quotechar="$", engine='python')
with open(path, 'r') as f:
self.assertEqual(f.read(), expected)

with tm.ensure_clean('test.csv') as path:
with tm.assertRaisesRegexp(TypeError, 'quotechar'):
df.to_csv(path, quoting=1, quotechar=None)
with tm.ensure_clean('test.csv') as path:
with tm.assertRaisesRegexp(TypeError, 'quotechar'):
df.to_csv(path, quoting=1, quotechar=None, engine='python')

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

from _csv import Error
with tm.ensure_clean('test.csv') as path:
with tm.assertRaisesRegexp(Error, 'escapechar'):
df.to_csv(path, doublequote=False) # no escapechar set
with tm.ensure_clean('test.csv') as path:
with tm.assertRaisesRegexp(Error, 'escapechar'):
df.to_csv(path, doublequote=False, engine='python')

def test_to_csv_escapechar(self):
df = DataFrame({'col': ['a"a', '"bb"']})
Expand All @@ -3203,11 +3185,6 @@ def test_to_csv_escapechar(self):
df.to_csv(path, quoting=1, doublequote=False, escapechar='\\')
with open(path, 'r') as f:
self.assertEqual(f.read(), expected)
with tm.ensure_clean('test.csv') as path:
df.to_csv(path, quoting=1, doublequote=False, escapechar='\\',
engine='python')
with open(path, 'r') as f:
self.assertEqual(f.read(), expected)

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

def test_csv_to_string(self):
df = DataFrame({'col': [1, 2]})
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ def test_to_csv_path_is_none(self):
# GH 8215
# Make sure we return string for consistency with
# Series.to_csv()
csv_str = self.frame.to_csv(path=None)
csv_str = self.frame.to_csv(path_or_buf=None)
self.assertIsInstance(csv_str, str)
recons = pd.read_csv(StringIO(csv_str), index_col=0)
assert_frame_equal(self.frame, recons)
Expand Down