Skip to content

DOC fix EX02 algorithms.factorize docstring #51243

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

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 0 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
MSG='Partially validate docstrings (EX02)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX02 --ignore_functions \
pandas.DataFrame.plot.line \
pandas.Index.factorize \
pandas.Period.strftime \
pandas.Series.factorize \
pandas.Series.floordiv \
pandas.Series.plot.line \
pandas.Series.rfloordiv \
Expand Down Expand Up @@ -612,7 +610,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.api.types.is_unsigned_integer_dtype \
pandas.core.groupby.DataFrameGroupBy.take \
pandas.core.groupby.SeriesGroupBy.take \
pandas.factorize \
pandas.io.formats.style.Styler.concat \
pandas.io.formats.style.Styler.export \
pandas.io.formats.style.Styler.set_td_classes \
Expand Down
14 changes: 7 additions & 7 deletions pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ def factorize(

>>> codes, uniques = pd.factorize(['b', 'b', 'a', 'c', 'b'])
>>> codes
array([0, 0, 1, 2, 0]...)
array([0, 0, 1, 2, 0], dtype=int64)
>>> uniques
array(['b', 'a', 'c'], dtype=object)

Expand All @@ -697,7 +697,7 @@ def factorize(

>>> codes, uniques = pd.factorize(['b', 'b', 'a', 'c', 'b'], sort=True)
>>> codes
array([1, 1, 0, 2, 1]...)
array([1, 1, 0, 2, 1], dtype=int64)
>>> uniques
array(['a', 'b', 'c'], dtype=object)

Expand All @@ -707,7 +707,7 @@ def factorize(

>>> codes, uniques = pd.factorize(['b', None, 'a', 'c', 'b'])
>>> codes
array([ 0, -1, 1, 2, 0]...)
array([ 0, -1, 1, 2, 0], dtype=int64)
>>> uniques
array(['b', 'a', 'c'], dtype=object)

Expand All @@ -718,7 +718,7 @@ def factorize(
>>> cat = pd.Categorical(['a', 'a', 'c'], categories=['a', 'b', 'c'])
>>> codes, uniques = pd.factorize(cat)
>>> codes
array([0, 0, 1]...)
array([0, 0, 1], dtype=int64)
>>> uniques
['a', 'c']
Categories (3, object): ['a', 'b', 'c']
Expand All @@ -732,7 +732,7 @@ def factorize(
>>> cat = pd.Series(['a', 'a', 'c'])
>>> codes, uniques = pd.factorize(cat)
>>> codes
array([0, 0, 1]...)
array([0, 0, 1], dtype=int64)
>>> uniques
Index(['a', 'c'], dtype='object')

Expand All @@ -742,13 +742,13 @@ def factorize(
>>> values = np.array([1, 2, 1, np.nan])
>>> codes, uniques = pd.factorize(values) # default: use_na_sentinel=True
>>> codes
array([ 0, 1, 0, -1])
array([ 0, 1, 0, -1], dtype=int64)
>>> uniques
array([1., 2.])

>>> codes, uniques = pd.factorize(values, use_na_sentinel=False)
>>> codes
array([0, 1, 0, 2])
array([0, 1, 0, 2], dtype=int64)
>>> uniques
array([ 1., 2., nan])
"""
Expand Down