Skip to content

DOC: fix api documentation for accessors #9721

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 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
6 changes: 6 additions & 0 deletions doc/_templates/autosummary/accessor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ fullname }}
{{ underline }}

.. currentmodule:: {{ module.split('.')[0] }}

.. automethod:: {{ [module.split('.')[1], objname]|join('.') }}
6 changes: 6 additions & 0 deletions doc/_templates/autosummary/class_without_autosummary.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ fullname }}
{{ underline }}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
54 changes: 42 additions & 12 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ These can be accessed like ``Series.dt.<property>``.
Series.dt.microsecond
Series.dt.nanosecond
Series.dt.second
Series.dt.week
Series.dt.weekofyear
Series.dt.dayofweek
Series.dt.weekday
Expand All @@ -481,6 +482,10 @@ These can be accessed like ``Series.dt.<property>``.
Series.dt.is_quarter_end
Series.dt.is_year_start
Series.dt.is_year_end
Series.dt.daysinmonth
Series.dt.days_in_month
Series.dt.tz
Series.dt.freq

**Datetime Methods**

Expand Down Expand Up @@ -575,29 +580,49 @@ strings and apply several methods to it. These can be acccessed like
Series.str.isdecimal
Series.str.get_dummies

..
The following is needed to ensure the generated pages are created with the
correct template (otherwise they would be created in the Series class page)

..
.. autosummary::
:toctree: generated/
:template: autosummary/accessor.rst

Series.str
Series.cat
Series.dt


.. _api.categorical:

Categorical
~~~~~~~~~~~

If the Series is of dtype ``category``, ``Series.cat`` can be used to change the the categorical
data. This accessor is similar to the ``Series.dt`` or ``Series.str`` and has the
following usable methods and properties (all available as ``Series.cat.<method_or_property>``).
following usable methods and properties:

.. autosummary::
:toctree: generated/
:template: autosummary/accessor_attribute.rst

Series.cat.categories
Series.cat.ordered
Series.cat.codes

.. autosummary::
:toctree: generated/
:template: autosummary/accessor_method.rst

Categorical.categories
Categorical.ordered
Categorical.rename_categories
Categorical.reorder_categories
Categorical.add_categories
Categorical.remove_categories
Categorical.remove_unused_categories
Categorical.set_categories
Categorical.as_ordered
Categorical.as_unordered
Categorical.codes
Series.cat.rename_categories
Series.cat.reorder_categories
Series.cat.add_categories
Series.cat.remove_categories
Series.cat.remove_unused_categories
Series.cat.set_categories
Series.cat.as_ordered
Series.cat.as_unordered

To create a Series of dtype ``category``, use ``cat = s.astype("category")``.

Expand All @@ -606,8 +631,13 @@ adding ordering information or special categories is need at creation time of th

.. autosummary::
:toctree: generated/
:template: autosummary/class_without_autosummary.rst

Categorical

.. autosummary::
:toctree: generated/

Categorical.from_codes

``np.asarray(categorical)`` works by implementing the array interface. Be aware, that this converts
Expand Down