Skip to content

Commit 1feafb5

Browse files
Aloqeelypmhatre1
authored andcommitted
DOC: Update Categorical/CategoricalDtype methods' docstring to pass docstring validation (pandas-dev#58079)
* Improve docstring for some methods in categorical/categoricaldtype * Remove cat.ordered --------- Co-authored-by: Abdulaziz Aloqeely <[email protected]>
1 parent b9c2f37 commit 1feafb5

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

ci/code_checks.sh

-10
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7070
--format=actions \
7171
-i ES01 `# For now it is ok if docstrings are missing the extended summary` \
7272
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
73-
-i "pandas.Categorical.__array__ SA01" \
74-
-i "pandas.Categorical.codes SA01" \
75-
-i "pandas.Categorical.dtype SA01" \
76-
-i "pandas.Categorical.from_codes SA01" \
77-
-i "pandas.Categorical.ordered SA01" \
78-
-i "pandas.CategoricalDtype.categories SA01" \
79-
-i "pandas.CategoricalDtype.ordered SA01" \
80-
-i "pandas.CategoricalIndex.codes SA01" \
81-
-i "pandas.CategoricalIndex.ordered SA01" \
8273
-i "pandas.DataFrame.__dataframe__ SA01" \
8374
-i "pandas.DataFrame.at_time PR01" \
8475
-i "pandas.DataFrame.kurt RT03,SA01" \
@@ -215,7 +206,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
215206
-i "pandas.Series.cat.as_ordered PR01" \
216207
-i "pandas.Series.cat.as_unordered PR01" \
217208
-i "pandas.Series.cat.codes SA01" \
218-
-i "pandas.Series.cat.ordered SA01" \
219209
-i "pandas.Series.cat.remove_categories PR01,PR02" \
220210
-i "pandas.Series.cat.remove_unused_categories PR01" \
221211
-i "pandas.Series.cat.rename_categories PR01,PR02" \

pandas/core/arrays/categorical.py

+28
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,11 @@ def dtype(self) -> CategoricalDtype:
497497
"""
498498
The :class:`~pandas.api.types.CategoricalDtype` for this instance.
499499
500+
See Also
501+
--------
502+
astype : Cast argument to a specified dtype.
503+
CategoricalDtype : Type for categorical data.
504+
500505
Examples
501506
--------
502507
>>> cat = pd.Categorical(["a", "b"], ordered=True)
@@ -721,6 +726,11 @@ def from_codes(
721726
-------
722727
Categorical
723728
729+
See Also
730+
--------
731+
codes : The category codes of the categorical.
732+
CategoricalIndex : An Index with an underlying ``Categorical``.
733+
724734
Examples
725735
--------
726736
>>> dtype = pd.CategoricalDtype(["a", "b"], ordered=True)
@@ -810,6 +820,12 @@ def ordered(self) -> Ordered:
810820
"""
811821
Whether the categories have an ordered relationship.
812822
823+
See Also
824+
--------
825+
set_ordered : Set the ordered attribute.
826+
as_ordered : Set the Categorical to be ordered.
827+
as_unordered : Set the Categorical to be unordered.
828+
813829
Examples
814830
--------
815831
For :class:`pandas.Series`:
@@ -861,6 +877,11 @@ def codes(self) -> np.ndarray:
861877
ndarray[int]
862878
A non-writable view of the ``codes`` array.
863879
880+
See Also
881+
--------
882+
Categorical.from_codes : Make a Categorical from codes.
883+
CategoricalIndex : An Index with an underlying ``Categorical``.
884+
864885
Examples
865886
--------
866887
For :class:`pandas.Categorical`:
@@ -1641,6 +1662,9 @@ def __array__(
16411662
"""
16421663
The numpy array interface.
16431664
1665+
Users should not call this directly. Rather, it is invoked by
1666+
:func:`numpy.array` and :func:`numpy.asarray`.
1667+
16441668
Parameters
16451669
----------
16461670
dtype : np.dtype or None
@@ -1656,6 +1680,10 @@ def __array__(
16561680
if dtype==None (default), the same dtype as
16571681
categorical.categories.dtype.
16581682
1683+
See Also
1684+
--------
1685+
numpy.asarray : Convert input to numpy.ndarray.
1686+
16591687
Examples
16601688
--------
16611689

pandas/core/dtypes/dtypes.py

+8
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,10 @@ def categories(self) -> Index:
623623
"""
624624
An ``Index`` containing the unique categories allowed.
625625
626+
See Also
627+
--------
628+
ordered : Whether the categories have an ordered relationship.
629+
626630
Examples
627631
--------
628632
>>> cat_type = pd.CategoricalDtype(categories=["a", "b"], ordered=True)
@@ -636,6 +640,10 @@ def ordered(self) -> Ordered:
636640
"""
637641
Whether the categories have an ordered relationship.
638642
643+
See Also
644+
--------
645+
categories : An Index containing the unique categories allowed.
646+
639647
Examples
640648
--------
641649
>>> cat_type = pd.CategoricalDtype(categories=["a", "b"], ordered=True)

0 commit comments

Comments
 (0)