Skip to content

Commit a53a26c

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

File tree

10 files changed

+105
-13
lines changed

10 files changed

+105
-13
lines changed

doc/source/api.rst

+48-2
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,53 @@ 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.ordinal
1657+
PeriodIndex.quarter
1658+
PeriodIndex.qyear
1659+
PeriodIndex.second
1660+
PeriodIndex.start_time
1661+
PeriodIndex.week
1662+
PeriodIndex.weekday
1663+
PeriodIndex.weekofyear
1664+
PeriodIndex.year
1665+
1666+
Methods
1667+
~~~~~~~
1668+
.. autosummary::
1669+
:toctree: generated/
1670+
1671+
PeriodIndex.asfreq
1672+
PeriodIndex.strftime
1673+
PeriodIndex.to_timestamp
1674+
PeriodIndex.tz_convert
1675+
PeriodIndex.tz_localize
1676+
16301677
Scalars
16311678
-------
16321679

@@ -1654,13 +1701,11 @@ Attributes
16541701
Period.is_leap_year
16551702
Period.minute
16561703
Period.month
1657-
Period.now
16581704
Period.ordinal
16591705
Period.quarter
16601706
Period.qyear
16611707
Period.second
16621708
Period.start_time
1663-
Period.strftime
16641709
Period.week
16651710
Period.weekday
16661711
Period.weekofyear
@@ -1672,6 +1717,7 @@ Methods
16721717
:toctree: generated/
16731718

16741719
Period.asfreq
1720+
Period.now
16751721
Period.strftime
16761722
Period.to_timestamp
16771723

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ class IntervalIndex(IntervalMixin, Index):
121121
Copy the meta-data
122122
123123
See Also
124-
--------
125-
Index
124+
---------
125+
Index : The base pandas Index type
126126
"""
127127
_typ = 'intervalindex'
128128
_comparables = ['name']

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)