diff --git a/doc/source/v0.15.0.txt b/doc/source/v0.15.0.txt index 2006b6e8462f3..a297fb6ad32ce 100644 --- a/doc/source/v0.15.0.txt +++ b/doc/source/v0.15.0.txt @@ -417,6 +417,9 @@ There are no prior version deprecations that are taking effect as of 0.15.0. Deprecations ~~~~~~~~~~~~ +The ``convert_dummies`` method has been deprecated in favor of +``get_dummies``(:issue:`8140`) + .. _whatsnew_0150.knownissues: Known Issues diff --git a/pandas/core/reshape.py b/pandas/core/reshape.py index 218c76c2b0cfb..3ba589b8fa35d 100644 --- a/pandas/core/reshape.py +++ b/pandas/core/reshape.py @@ -979,6 +979,12 @@ def convert_dummies(data, cat_variables, prefix_sep='_'): ------- dummies : DataFrame """ + import warnings + + warnings.warn("'convert_dummies' is deprecated and will be removed " + "in a future release. Use 'get_dummies' instead.", + FutureWarning) + result = data.drop(cat_variables, axis=1) for variable in cat_variables: dummies = _get_dummies_1d(data[variable], prefix=variable, diff --git a/pandas/tests/test_reshape.py b/pandas/tests/test_reshape.py index 46ab983a4fbd9..3cc2d94789a8d 100644 --- a/pandas/tests/test_reshape.py +++ b/pandas/tests/test_reshape.py @@ -331,8 +331,9 @@ def test_convert_dummies(self): 'C': np.random.randn(8), 'D': np.random.randn(8)}) - result = convert_dummies(df, ['A', 'B']) - result2 = convert_dummies(df, ['A', 'B'], prefix_sep='.') + with tm.assert_produces_warning(FutureWarning): + result = convert_dummies(df, ['A', 'B']) + result2 = convert_dummies(df, ['A', 'B'], prefix_sep='.') expected = DataFrame({'A_foo': [1, 0, 1, 0, 1, 0, 1, 1], 'A_bar': [0, 1, 0, 1, 0, 1, 0, 0],