Skip to content

Commit

Permalink
DEPR: deprecate convert_dummies
Browse files Browse the repository at this point in the history
add depr to doc
  • Loading branch information
TomAugspurger committed Aug 31, 2014
1 parent 78ccfac commit f6a8a6d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions doc/source/v0.15.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions pandas/core/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/test_reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit f6a8a6d

Please sign in to comment.