Skip to content

Commit e88bb31

Browse files
author
tp
committed
Add references for different index types + examples for pd.Index
1 parent e2a0251 commit e88bb31

File tree

10 files changed

+103
-12
lines changed

10 files changed

+103
-12
lines changed

doc/source/api.rst

+47-2
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,52 @@ Conversion
16271627

16281628
.. currentmodule:: pandas
16291629

1630+
PeriodIndex
1631+
--------------
1632+
1633+
.. autosummary::
1634+
:toctree: generated/
1635+
:template: autosummary/class_without_autosummary.rst
1636+
1637+
PeriodIndex
1638+
1639+
Attributes
1640+
~~~~~~~~~~
1641+
.. autosummary::
1642+
:toctree: generated/
1643+
1644+
PeriodIndex.day
1645+
PeriodIndex.dayofweek
1646+
PeriodIndex.dayofyear
1647+
PeriodIndex.days_in_month
1648+
PeriodIndex.daysinmonth
1649+
PeriodIndex.end_time
1650+
PeriodIndex.freq
1651+
PeriodIndex.freqstr
1652+
PeriodIndex.hour
1653+
PeriodIndex.is_leap_year
1654+
PeriodIndex.minute
1655+
PeriodIndex.month
1656+
PeriodIndex.quarter
1657+
PeriodIndex.qyear
1658+
PeriodIndex.second
1659+
PeriodIndex.start_time
1660+
PeriodIndex.week
1661+
PeriodIndex.weekday
1662+
PeriodIndex.weekofyear
1663+
PeriodIndex.year
1664+
1665+
Methods
1666+
~~~~~~~
1667+
.. autosummary::
1668+
:toctree: generated/
1669+
1670+
PeriodIndex.asfreq
1671+
PeriodIndex.strftime
1672+
PeriodIndex.to_timestamp
1673+
PeriodIndex.tz_convert
1674+
PeriodIndex.tz_localize
1675+
16301676
Scalars
16311677
-------
16321678

@@ -1654,13 +1700,11 @@ Attributes
16541700
Period.is_leap_year
16551701
Period.minute
16561702
Period.month
1657-
Period.now
16581703
Period.ordinal
16591704
Period.quarter
16601705
Period.qyear
16611706
Period.second
16621707
Period.start_time
1663-
Period.strftime
16641708
Period.week
16651709
Period.weekday
16661710
Period.weekofyear
@@ -1672,6 +1716,7 @@ Methods
16721716
:toctree: generated/
16731717

16741718
Period.asfreq
1719+
Period.now
16751720
Period.strftime
16761721
Period.to_timestamp
16771722

doc/sphinxext/numpydoc/numpydoc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def mangle_docstrings(app, what, name, obj, options, lines,
4545
# PANDAS HACK (to remove the list of methods/attributes for Categorical)
4646
no_autosummary = [".Categorical", "CategoricalIndex", "IntervalIndex",
4747
"RangeIndex", "Int64Index", "UInt64Index",
48-
"Float64Index"]
48+
"Float64Index", "PeriodIndex"]
4949
if what == "class" and any(name.endswith(n) for n in no_autosummary):
5050
cfg['class_members_list'] = False
5151

pandas/core/indexes/base.py

+18
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,24 @@ class Index(IndexOpsMixin, PandasObject):
123123
Notes
124124
-----
125125
An Index instance can **only** contain hashable objects
126+
127+
Examples
128+
--------
129+
>>> pd.Index([1, 2, 3])
130+
Int64Index([1, 2, 3], dtype='int64')
131+
132+
>>> pd.Index(list('abc'))
133+
Index(['a', 'b', 'c'], dtype='object')
134+
135+
See Also
136+
---------
137+
RangeIndex : Index implementing a monotonic integer range (very
138+
memory-efficient)
139+
CategoricalIndex : Index of :class:`Categorical` s.
140+
MultiIndex : A multi-level, or hierarchical, Index
141+
IntervalIndex : an Index of :class:`Interval` s.
142+
DatetimeIndex, TimedeltaIndex, PeriodIndex
143+
Int64Index, UInt64Index, Float64Index
126144
"""
127145
# To hand over control to subclasses
128146
_join_precedence = 1

pandas/core/indexes/datetimes.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,14 @@ class DatetimeIndex(DatelikeOps, TimelikeOps, DatetimeIndexOpsMixin,
206206
207207
Notes
208208
-----
209-
210209
To learn more about the frequency strings, please see `this link
211210
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
211+
212+
See Also
213+
---------
214+
Index : The base pandas Index type
215+
TimedeltaIndex : Index of timedelta64 data
216+
PeriodIndex : Index of Period data
212217
"""
213218

214219
_typ = 'datetimeindex'

pandas/core/indexes/interval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class IntervalIndex(IntervalMixin, Index):
147147
148148
See Also
149149
--------
150-
Index
150+
Index : The base pandas Index type
151151
Interval : A bounded slice-like interval
152152
interval_range : Function to create a fixed frequency
153153
IntervalIndex, IntervalIndex.from_arrays, IntervalIndex.from_breaks,

pandas/core/indexes/multi.py

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class MultiIndex(Index):
9595
MultiIndex.from_product : Create a MultiIndex from the cartesian product
9696
of iterables
9797
MultiIndex.from_tuples : Convert list of tuples to a MultiIndex
98+
Index : The base pandas Index type
9899
"""
99100

100101
# initialize to zero-length tuples to make everything work

pandas/core/indexes/numeric.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,21 @@ def is_all_dates(self):
108108
Make a copy of input ndarray
109109
name : object
110110
Name to be stored in the index
111+
111112
Notes
112113
-----
113114
An Index instance can **only** contain hashable objects.
115+
116+
See also
117+
--------
118+
Index : The base pandas Index type
114119
"""
115120

116121
_int64_descr_args = dict(
117122
klass='Int64Index',
118123
ltype='integer',
119124
dtype='int64',
120-
extra="""This is the default index type used
121-
by the DataFrame and Series ctors when no explicit
122-
index is provided by the user.
123-
"""
125+
extra=''
124126
)
125127

126128

pandas/core/indexes/period.py

+7
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ class PeriodIndex(DatelikeOps, DatetimeIndexOpsMixin, Int64Index):
163163
>>> idx = PeriodIndex(year=year_arr, quarter=q_arr)
164164
165165
>>> idx2 = PeriodIndex(start='2000', end='2010', freq='A')
166+
167+
See Also
168+
---------
169+
Index : The base pandas Index type
170+
Period : Represents a period of time
171+
DatetimeIndex : Index with datetime64 data
172+
TimedeltaIndex : Index of timedelta64 data
166173
"""
167174
_box_scalars = True
168175
_typ = 'periodindex'

pandas/core/indexes/range.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
class RangeIndex(Int64Index):
2424

2525
"""
26-
Immutable Index implementing a monotonic range. RangeIndex is a
27-
memory-saving special case of Int64Index limited to representing
28-
monotonic ranges.
26+
Immutable Index implementing a monotonic integer range.
27+
28+
RangeIndex is a memory-saving special case of Int64Index limited to
29+
representing monotonic ranges. This is the default index type used
30+
by DataFrame and Series when no explicit index is provided by the user.
2931
3032
Parameters
3133
----------
@@ -38,6 +40,10 @@ class RangeIndex(Int64Index):
3840
copy : bool, default False
3941
Unused, accepted for homogeneity with other index types.
4042
43+
See Also
44+
--------
45+
Index : The base pandas Index type
46+
Int64Index : Index of int64 data
4147
"""
4248

4349
_typ = 'rangeindex'

pandas/core/indexes/timedeltas.py

+7
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ class TimedeltaIndex(DatetimeIndexOpsMixin, TimelikeOps, Int64Index):
114114
115115
To learn more about the frequency strings, please see `this link
116116
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
117+
118+
See Also
119+
---------
120+
Index : The base pandas Index type
121+
Timedelta : Represents a duration between two dates or times.
122+
DatetimeIndex : Index of datetime64 data
123+
PeriodIndex : Index of Period data
117124
"""
118125

119126
_typ = 'timedeltaindex'

0 commit comments

Comments
 (0)