Skip to content

DOC: Update Categorical/CategoricalDtype methods' docstring to pass docstring validation #58079

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 3 commits into from
Apr 29, 2024
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
10 changes: 0 additions & 10 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
--format=actions \
-i ES01 `# For now it is ok if docstrings are missing the extended summary` \
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
-i "pandas.Categorical.__array__ SA01" \
-i "pandas.Categorical.codes SA01" \
-i "pandas.Categorical.dtype SA01" \
-i "pandas.Categorical.from_codes SA01" \
-i "pandas.Categorical.ordered SA01" \
-i "pandas.CategoricalDtype.categories SA01" \
-i "pandas.CategoricalDtype.ordered SA01" \
-i "pandas.CategoricalIndex.codes SA01" \
-i "pandas.CategoricalIndex.ordered SA01" \
-i "pandas.DataFrame.__dataframe__ SA01" \
-i "pandas.DataFrame.at_time PR01" \
-i "pandas.DataFrame.kurt RT03,SA01" \
Expand Down Expand Up @@ -232,7 +223,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Series.cat.as_ordered PR01" \
-i "pandas.Series.cat.as_unordered PR01" \
-i "pandas.Series.cat.codes SA01" \
-i "pandas.Series.cat.ordered SA01" \
-i "pandas.Series.cat.remove_categories PR01,PR02" \
-i "pandas.Series.cat.remove_unused_categories PR01" \
-i "pandas.Series.cat.rename_categories PR01,PR02" \
Expand Down
28 changes: 28 additions & 0 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ def dtype(self) -> CategoricalDtype:
"""
The :class:`~pandas.api.types.CategoricalDtype` for this instance.

See Also
--------
astype : Cast argument to a specified dtype.
CategoricalDtype : Type for categorical data.

Examples
--------
>>> cat = pd.Categorical(["a", "b"], ordered=True)
Expand Down Expand Up @@ -721,6 +726,11 @@ def from_codes(
-------
Categorical

See Also
--------
codes : The category codes of the categorical.
CategoricalIndex : An Index with an underlying ``Categorical``.

Examples
--------
>>> dtype = pd.CategoricalDtype(["a", "b"], ordered=True)
Expand Down Expand Up @@ -810,6 +820,12 @@ def ordered(self) -> Ordered:
"""
Whether the categories have an ordered relationship.

See Also
--------
set_ordered : Set the ordered attribute.
as_ordered : Set the Categorical to be ordered.
as_unordered : Set the Categorical to be unordered.

Examples
--------
For :class:`pandas.Series`:
Expand Down Expand Up @@ -861,6 +877,11 @@ def codes(self) -> np.ndarray:
ndarray[int]
A non-writable view of the ``codes`` array.

See Also
--------
Categorical.from_codes : Make a Categorical from codes.
CategoricalIndex : An Index with an underlying ``Categorical``.

Examples
--------
For :class:`pandas.Categorical`:
Expand Down Expand Up @@ -1641,6 +1662,9 @@ def __array__(
"""
The numpy array interface.

Users should not call this directly. Rather, it is invoked by
:func:`numpy.array` and :func:`numpy.asarray`.

Parameters
----------
dtype : np.dtype or None
Expand All @@ -1656,6 +1680,10 @@ def __array__(
if dtype==None (default), the same dtype as
categorical.categories.dtype.

See Also
--------
numpy.asarray : Convert input to numpy.ndarray.

Examples
--------

Expand Down
8 changes: 8 additions & 0 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ def categories(self) -> Index:
"""
An ``Index`` containing the unique categories allowed.

See Also
--------
ordered : Whether the categories have an ordered relationship.

Examples
--------
>>> cat_type = pd.CategoricalDtype(categories=["a", "b"], ordered=True)
Expand All @@ -635,6 +639,10 @@ def ordered(self) -> Ordered:
"""
Whether the categories have an ordered relationship.

See Also
--------
categories : An Index containing the unique categories allowed.

Examples
--------
>>> cat_type = pd.CategoricalDtype(categories=["a", "b"], ordered=True)
Expand Down