From eda1924bd313476436742c653e08307ce232f36f Mon Sep 17 00:00:00 2001 From: taeold Date: Tue, 13 Oct 2015 16:48:55 -0700 Subject: [PATCH] DEPR: deprecate engine keyword from to_csv #11274 --- doc/source/whatsnew/v0.17.1.txt | 2 ++ pandas/core/format.py | 7 ++++++- pandas/tests/test_format.py | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.17.1.txt b/doc/source/whatsnew/v0.17.1.txt index b9e674c819e49..507c829e5763f 100755 --- a/doc/source/whatsnew/v0.17.1.txt +++ b/doc/source/whatsnew/v0.17.1.txt @@ -44,6 +44,8 @@ Deprecations ^^^^^^^^^^^^ - The ``pandas.io.ga`` module which implements ``google-analytics`` support is deprecated and will be removed in a future version (:issue:`11308`) +- Deprecate the ``engine`` keyword from ``.to_csv()``, which will be removed in a future version (:issue:`11274`) + .. _whatsnew_0171.performance: diff --git a/pandas/core/format.py b/pandas/core/format.py index bf9b3bc8040de..8899e72cb2d48 100644 --- a/pandas/core/format.py +++ b/pandas/core/format.py @@ -23,6 +23,7 @@ import itertools import csv +import warnings common_docstring = """ Parameters @@ -1264,7 +1265,11 @@ def __init__(self, obj, path_or_buf=None, sep=",", na_rep='', float_format=None, tupleize_cols=False, quotechar='"', date_format=None, doublequote=True, escapechar=None, decimal='.'): - self.engine = engine # remove for 0.13 + if engine is not None: + warnings.warn("'engine' keyword is deprecated and " + "will be removed in a future version", + FutureWarning, stacklevel=3) + self.engine = engine # remove for 0.18 self.obj = obj if path_or_buf is None: diff --git a/pandas/tests/test_format.py b/pandas/tests/test_format.py index bf2cfc6216a60..140b54225b8e8 100644 --- a/pandas/tests/test_format.py +++ b/pandas/tests/test_format.py @@ -2952,6 +2952,12 @@ def test_to_csv_date_format(self): self.assertEqual(df_day.to_csv(), expected_default_day) self.assertEqual(df_day.to_csv(date_format='%Y-%m-%d'), expected_default_day) + # deprecation GH11274 + def test_to_csv_engine_kw_deprecation(self): + with tm.assert_produces_warning(FutureWarning): + df = DataFrame({'col1' : [1], 'col2' : ['a'], 'col3' : [10.1] }) + df.to_csv(engine='python') + def test_round_dataframe(self): # GH 2665