Skip to content

Commit

Permalink
DOC: Remove numpydoc hack, list methods explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger committed Nov 9, 2017
1 parent 2f9d4fb commit 500ab71
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 7 deletions.
29 changes: 29 additions & 0 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,12 @@ The dtype of a ``Categorical`` can be described by a :class:`pandas.api.types.Ca

api.types.CategoricalDtype

.. autosummary::
:toctree: generated/

api.types.CategoricalDtype.categories
api.types.CategoricalDtype.ordered

If the Series is of dtype ``CategoricalDtype``, ``Series.cat`` can be used to change the categorical
data. This accessor is similar to the ``Series.dt`` or ``Series.str`` and has the
following usable methods and properties:
Expand Down Expand Up @@ -692,6 +698,9 @@ adding ordering information or special categories is need at creation time of th
.. autosummary::
:toctree: generated/

Categorical.categories
Categorical.ordered
Categorical.codes
Categorical.from_codes

``np.asarray(categorical)`` works by implementing the array interface. Be aware, that this converts
Expand Down Expand Up @@ -1438,6 +1447,15 @@ Numeric Index
UInt64Index
Float64Index

.. We need this autosummary so that the methods are generated.
.. Separate block, since they aren't classes.
.. autosummary::
:toctree: generated/

RangeIndex.from_range


.. _api.categoricalindex:

CategoricalIndex
Expand Down Expand Up @@ -1466,6 +1484,8 @@ Categorical Components
CategoricalIndex.set_categories
CategoricalIndex.as_ordered
CategoricalIndex.as_unordered
CategoricalIndex.get_loc
CategoricalIndex.map

.. _api.intervalindex:

Expand All @@ -1488,6 +1508,15 @@ IntervalIndex Components
IntervalIndex.from_tuples
IntervalIndex.from_breaks
IntervalIndex.from_intervals
IntervalIndex.contains
IntervalIndex.get_loc
IntervalIndex.left
IntervalIndex.right
IntervalIndex.mid
IntervalIndex.closed
IntervalIndex.values
IntervalIndex.is_non_overlapping_monotonic


.. _api.multiindex:

Expand Down
1 change: 1 addition & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
]

exclude_patterns = ['**.ipynb_checkpoints']
numpydoc_show_class_members = False

with open("index.rst") as f:
index_rst_lines = f.readlines()
Expand Down
7 changes: 0 additions & 7 deletions doc/sphinxext/numpydoc/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ def mangle_docstrings(app, what, name, obj, options, lines,
class_members_toctree=app.config.numpydoc_class_members_toctree,
)

# PANDAS HACK (to remove the list of methods/attributes for Categorical)
no_autosummary = [".Categorical", "CategoricalIndex", "IntervalIndex",
"RangeIndex", "Int64Index", "UInt64Index",
"Float64Index", "PeriodIndex", "CategoricalDtype"]
if what == "class" and any(name.endswith(n) for n in no_autosummary):
cfg['class_members_list'] = False

if what == 'module':
# Strip top title
title_re = re.compile(sixu('^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*'),
Expand Down
5 changes: 5 additions & 0 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class CategoricalDtype(ExtensionDtype):
Must be unique, and must not contain any nulls.
ordered : bool, default False
Attributes
----------
categories
ordered
Notes
-----
This class is useful for specifying the type of a ``Categorical``
Expand Down
19 changes: 19 additions & 0 deletions pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ class CategoricalIndex(Index, accessor.PandasDelegate):
See Also
--------
Categorical, Index
Methods
-------
rename_categories
reorder_categories
add_categories
remove_categories
remove_unused_categories
set_categories
as_ordered
as_unordered
get_loc
map
Attributes
----------
codes
categories
ordered
"""

_typ = 'categoricalindex'
Expand Down
18 changes: 18 additions & 0 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,24 @@ class IntervalIndex(IntervalMixin, Index):
IntervalIndex.from_intervals, IntervalIndex.from_tuples
cut, qcut : convert arrays of continuous data into categoricals/series of
``Interval``.
Methods
-------
from_arrays
from_tuples
from_breaks
from_intervals
contains
get_loc
Attributes
----------
left
right
mid
closed
values
is_non_overlapping_monotonic
"""
_typ = 'intervalindex'
_comparables = ['name']
Expand Down
31 changes: 31 additions & 0 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,37 @@ class PeriodIndex(DatelikeOps, DatetimeIndexOpsMixin, Int64Index):
Timezone for converting datetime64 data to Periods
dtype : str or PeriodDtype, default None
Attributes
----------
day
dayofweek
dayofyear
days_in_month
daysinmonth
end_time
freq
freqstr
hour
is_leap_year
minute
month
quarter
qyear
second
start_time
week
weekday
weekofyear
year
Methods
-------
asfreq
strftime
to_timestamp
tz_convert
tz_localize
Examples
--------
>>> idx = PeriodIndex(year=year_arr, quarter=q_arr)
Expand Down
4 changes: 4 additions & 0 deletions pandas/core/indexes/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class RangeIndex(Int64Index):
--------
Index : The base pandas Index type
Int64Index : Index of int64 data
Methods
-------
from_range
"""

_typ = 'rangeindex'
Expand Down

0 comments on commit 500ab71

Please sign in to comment.