Skip to content

Commit f07a407

Browse files
author
TomAugspurger
committed
Deprecate order kwarg in factorize
1 parent ac9b247 commit f07a407

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

doc/source/release.rst

+2
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ Deprecations
206206
``periods`` with a default value of 1. A ``FutureWarning`` is raised if the
207207
old argument ``lags`` is used by name. (:issue:`6910`)
208208

209+
- The ``order`` keyword argument of :func:`factorize` will be removed. (:issue:`6926`).
210+
209211
Prior Version Deprecations/Changes
210212
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
211213

doc/source/v0.14.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ Deprecations
420420
The old positional argument ``lags`` has been changed to a keyword argument
421421
``periods`` with a default value of 1. A ``FutureWarning`` is raised if the
422422
old argument ``lags`` is used by name. (:issue:`6910`)
423+
- The ``order`` keyword argument of :func:`factorize` will be removed. (:issue:`6926`).
423424

424425
.. _whatsnew_0140.enhancements:
425426

pandas/core/algorithms.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pandas.hashtable as htable
1212
import pandas.compat as compat
1313
from pandas.compat import filter, string_types
14+
from pandas.util.decorators import deprecate_kwarg
1415

1516
def match(to_match, values, na_sentinel=-1):
1617
"""
@@ -104,7 +105,7 @@ def factorize(values, sort=False, order=None, na_sentinel=-1):
104105
Sequence
105106
sort : boolean, default False
106107
Sort by values
107-
order :
108+
order : deprecated
108109
na_sentinel: int, default -1
109110
Value to mark "not found"
110111
@@ -115,6 +116,10 @@ def factorize(values, sort=False, order=None, na_sentinel=-1):
115116
116117
note: an array of Periods will ignore sort as it returns an always sorted PeriodIndex
117118
"""
119+
if order is not None:
120+
warn("order is deprecated."
121+
"See https://github.com/pydata/pandas/issues/6926", FutureWarning)
122+
118123
from pandas.tseries.period import PeriodIndex
119124
vals = np.asarray(values)
120125
is_datetime = com.is_datetime64_dtype(vals)

pandas/tests/test_algos.py

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ def test_strings(self):
4747
class TestFactorize(tm.TestCase):
4848
_multiprocess_can_split_ = True
4949

50+
def test_warn(self):
51+
52+
s = Series([1, 2, 3])
53+
with tm.assert_produces_warning(FutureWarning):
54+
algos.factorize(s, order='A')
55+
5056
def test_basic(self):
5157

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

0 commit comments

Comments
 (0)