Skip to content
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

API/DEPR: Deprecate order kwarg in factorize #6930

Merged
merged 1 commit into from
Apr 22, 2014
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
2 changes: 2 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ Deprecations
``periods`` with a default value of 1. A ``FutureWarning`` is raised if the
old argument ``lags`` is used by name. (:issue:`6910`)

- The ``order`` keyword argument of :func:`factorize` will be removed. (:issue:`6926`).

Prior Version Deprecations/Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
1 change: 1 addition & 0 deletions doc/source/v0.14.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ Deprecations
The old positional argument ``lags`` has been changed to a keyword argument
``periods`` with a default value of 1. A ``FutureWarning`` is raised if the
old argument ``lags`` is used by name. (:issue:`6910`)
- The ``order`` keyword argument of :func:`factorize` will be removed. (:issue:`6926`).

.. _whatsnew_0140.enhancements:

Expand Down
7 changes: 6 additions & 1 deletion pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pandas.hashtable as htable
import pandas.compat as compat
from pandas.compat import filter, string_types
from pandas.util.decorators import deprecate_kwarg

def match(to_match, values, na_sentinel=-1):
"""
Expand Down Expand Up @@ -104,7 +105,7 @@ def factorize(values, sort=False, order=None, na_sentinel=-1):
Sequence
sort : boolean, default False
Sort by values
order :
order : deprecated
na_sentinel: int, default -1
Value to mark "not found"

Expand All @@ -115,6 +116,10 @@ def factorize(values, sort=False, order=None, na_sentinel=-1):

note: an array of Periods will ignore sort as it returns an always sorted PeriodIndex
"""
if order is not None:
warn("order is deprecated."
"See https://github.com/pydata/pandas/issues/6926", FutureWarning)

from pandas.tseries.period import PeriodIndex
vals = np.asarray(values)
is_datetime = com.is_datetime64_dtype(vals)
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def test_strings(self):
class TestFactorize(tm.TestCase):
_multiprocess_can_split_ = True

def test_warn(self):

s = Series([1, 2, 3])
with tm.assert_produces_warning(FutureWarning):
algos.factorize(s, order='A')

def test_basic(self):

labels, uniques = algos.factorize(['a', 'b', 'b', 'a',
Expand Down