Skip to content

Commit 500ab71

Browse files
committed
DOC: Remove numpydoc hack, list methods explicitly
1 parent 2f9d4fb commit 500ab71

File tree

8 files changed

+107
-7
lines changed

8 files changed

+107
-7
lines changed

doc/source/api.rst

+29
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,12 @@ The dtype of a ``Categorical`` can be described by a :class:`pandas.api.types.Ca
653653

654654
api.types.CategoricalDtype
655655

656+
.. autosummary::
657+
:toctree: generated/
658+
659+
api.types.CategoricalDtype.categories
660+
api.types.CategoricalDtype.ordered
661+
656662
If the Series is of dtype ``CategoricalDtype``, ``Series.cat`` can be used to change the categorical
657663
data. This accessor is similar to the ``Series.dt`` or ``Series.str`` and has the
658664
following usable methods and properties:
@@ -692,6 +698,9 @@ adding ordering information or special categories is need at creation time of th
692698
.. autosummary::
693699
:toctree: generated/
694700

701+
Categorical.categories
702+
Categorical.ordered
703+
Categorical.codes
695704
Categorical.from_codes
696705

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

1450+
.. We need this autosummary so that the methods are generated.
1451+
.. Separate block, since they aren't classes.
1452+
1453+
.. autosummary::
1454+
:toctree: generated/
1455+
1456+
RangeIndex.from_range
1457+
1458+
14411459
.. _api.categoricalindex:
14421460

14431461
CategoricalIndex
@@ -1466,6 +1484,8 @@ Categorical Components
14661484
CategoricalIndex.set_categories
14671485
CategoricalIndex.as_ordered
14681486
CategoricalIndex.as_unordered
1487+
CategoricalIndex.get_loc
1488+
CategoricalIndex.map
14691489

14701490
.. _api.intervalindex:
14711491

@@ -1488,6 +1508,15 @@ IntervalIndex Components
14881508
IntervalIndex.from_tuples
14891509
IntervalIndex.from_breaks
14901510
IntervalIndex.from_intervals
1511+
IntervalIndex.contains
1512+
IntervalIndex.get_loc
1513+
IntervalIndex.left
1514+
IntervalIndex.right
1515+
IntervalIndex.mid
1516+
IntervalIndex.closed
1517+
IntervalIndex.values
1518+
IntervalIndex.is_non_overlapping_monotonic
1519+
14911520

14921521
.. _api.multiindex:
14931522

doc/source/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
]
6969

7070
exclude_patterns = ['**.ipynb_checkpoints']
71+
numpydoc_show_class_members = False
7172

7273
with open("index.rst") as f:
7374
index_rst_lines = f.readlines()

doc/sphinxext/numpydoc/numpydoc.py

-7
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ def mangle_docstrings(app, what, name, obj, options, lines,
4242
class_members_toctree=app.config.numpydoc_class_members_toctree,
4343
)
4444

45-
# PANDAS HACK (to remove the list of methods/attributes for Categorical)
46-
no_autosummary = [".Categorical", "CategoricalIndex", "IntervalIndex",
47-
"RangeIndex", "Int64Index", "UInt64Index",
48-
"Float64Index", "PeriodIndex", "CategoricalDtype"]
49-
if what == "class" and any(name.endswith(n) for n in no_autosummary):
50-
cfg['class_members_list'] = False
51-
5245
if what == 'module':
5346
# Strip top title
5447
title_re = re.compile(sixu('^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*'),

pandas/core/dtypes/dtypes.py

+5
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ class CategoricalDtype(ExtensionDtype):
120120
Must be unique, and must not contain any nulls.
121121
ordered : bool, default False
122122
123+
Attributes
124+
----------
125+
categories
126+
ordered
127+
123128
Notes
124129
-----
125130
This class is useful for specifying the type of a ``Categorical``

pandas/core/indexes/category.py

+19
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ class CategoricalIndex(Index, accessor.PandasDelegate):
4949
See Also
5050
--------
5151
Categorical, Index
52+
53+
Methods
54+
-------
55+
rename_categories
56+
reorder_categories
57+
add_categories
58+
remove_categories
59+
remove_unused_categories
60+
set_categories
61+
as_ordered
62+
as_unordered
63+
get_loc
64+
map
65+
66+
Attributes
67+
----------
68+
codes
69+
categories
70+
ordered
5271
"""
5372

5473
_typ = 'categoricalindex'

pandas/core/indexes/interval.py

+18
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,24 @@ class IntervalIndex(IntervalMixin, Index):
154154
IntervalIndex.from_intervals, IntervalIndex.from_tuples
155155
cut, qcut : convert arrays of continuous data into categoricals/series of
156156
``Interval``.
157+
158+
Methods
159+
-------
160+
from_arrays
161+
from_tuples
162+
from_breaks
163+
from_intervals
164+
contains
165+
get_loc
166+
167+
Attributes
168+
----------
169+
left
170+
right
171+
mid
172+
closed
173+
values
174+
is_non_overlapping_monotonic
157175
"""
158176
_typ = 'intervalindex'
159177
_comparables = ['name']

pandas/core/indexes/period.py

+31
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,37 @@ class PeriodIndex(DatelikeOps, DatetimeIndexOpsMixin, Int64Index):
160160
Timezone for converting datetime64 data to Periods
161161
dtype : str or PeriodDtype, default None
162162
163+
Attributes
164+
----------
165+
day
166+
dayofweek
167+
dayofyear
168+
days_in_month
169+
daysinmonth
170+
end_time
171+
freq
172+
freqstr
173+
hour
174+
is_leap_year
175+
minute
176+
month
177+
quarter
178+
qyear
179+
second
180+
start_time
181+
week
182+
weekday
183+
weekofyear
184+
year
185+
186+
Methods
187+
-------
188+
asfreq
189+
strftime
190+
to_timestamp
191+
tz_convert
192+
tz_localize
193+
163194
Examples
164195
--------
165196
>>> idx = PeriodIndex(year=year_arr, quarter=q_arr)

pandas/core/indexes/range.py

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class RangeIndex(Int64Index):
4848
--------
4949
Index : The base pandas Index type
5050
Int64Index : Index of int64 data
51+
52+
Methods
53+
-------
54+
from_range
5155
"""
5256

5357
_typ = 'rangeindex'

0 commit comments

Comments
 (0)