Skip to content

Commit 19df70c

Browse files
author
araraonline
committed
Add Parameters and Returns to docstrings
1 parent efb5dc0 commit 19df70c

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

pandas/core/indexes/api.py

+75
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,23 @@ def _get_objs_combined_axis(objs, intersect=False, axis=0, sort=True):
4747
"""Extract combined index: return intersection or union (depending on the
4848
value of "intersect") of indexes on given axis, or None if all objects
4949
lack indexes (e.g. they are numpy arrays)
50+
51+
Parameters
52+
----------
53+
objs: list of objects
54+
Each object will only be considered if it has a _get_axis
55+
attribute
56+
intersect: boolean, default False
57+
If True, calculate the intersection between indexes. Otherwise,
58+
calculate the union
59+
axis: {0 or 'index', 1 or 'outer'}, default 0
60+
The axis to extract indexes from
61+
sort: boolean, default True
62+
Whether the result index should come out sorted or not
63+
64+
Returns
65+
-------
66+
Index
5067
"""
5168
obs_idxes = [obj._get_axis(axis) for obj in objs
5269
if hasattr(obj, '_get_axis')]
@@ -56,6 +73,19 @@ def _get_objs_combined_axis(objs, intersect=False, axis=0, sort=True):
5673

5774
def _get_combined_index(indexes, intersect=False, sort=False):
5875
"""Return the union or intersection of indexes
76+
77+
Parameters
78+
----------
79+
indexes: a list of Index or array-like objects
80+
intersect: boolean, default False
81+
If True, calculate the intersection between indexes. Otherwise,
82+
calculate the union
83+
sort: boolean, default False
84+
Whether the result index should come out sorted or not
85+
86+
Returns
87+
-------
88+
Index
5989
"""
6090

6191
# TODO: handle index names!
@@ -84,6 +114,16 @@ def _union_indexes(indexes, sort=True):
84114
"""Return the union of indexes
85115
86116
The behavior of sort and names is not consistent.
117+
118+
Parameters
119+
----------
120+
indexes: a list of Index or array-like objects
121+
sort: boolean, default True
122+
Whether the result index should come out sorted or not
123+
124+
Returns
125+
-------
126+
Index
87127
"""
88128
if len(indexes) == 0:
89129
raise AssertionError('Must have at least 1 Index to union')
@@ -99,6 +139,14 @@ def _unique_indices(inds):
99139
"""Convert indexes to lists and concatenate them, removing duplicates
100140
101141
The final dtype is inferred.
142+
143+
Parameters
144+
----------
145+
inds: a list of Index or array-like objects
146+
147+
Returns
148+
-------
149+
Index
102150
"""
103151
def conv(i):
104152
if isinstance(i, Index):
@@ -147,6 +195,15 @@ def _sanitize_and_check(indexes):
147195
Lists are sorted and converted to Index
148196
- [Index, Index, ...]: Return ([Index, Index, ...], TYPE)
149197
TYPE = 'special' if at least one special type, 'array' otherwise
198+
199+
Parameters
200+
----------
201+
indexes: a list of Index or array-like objects
202+
203+
Returns
204+
-------
205+
sanitized_indexes: list of Index or array-like objects
206+
type: {'list', 'array', 'special'}
150207
"""
151208
kinds = list({type(index) for index in indexes})
152209

@@ -170,6 +227,15 @@ def _get_consensus_names(indexes):
170227
171228
If there's exactly one non-empty 'names', return this,
172229
otherwise, return empty.
230+
231+
Parameters
232+
----------
233+
indexes: a list of index objects
234+
235+
Returns
236+
-------
237+
list
238+
A list representing the consensus 'names' found
173239
"""
174240

175241
# find the non-none names, need to tupleify to make
@@ -183,6 +249,15 @@ def _get_consensus_names(indexes):
183249

184250
def _all_indexes_same(indexes):
185251
"""Determine if all indexes contain the same elements
252+
253+
Parameters
254+
----------
255+
indexes: a list of Index objects
256+
257+
Returns
258+
-------
259+
boolean
260+
True if all indexes share the same values, False otherwise
186261
"""
187262
first = indexes[0]
188263
for index in indexes[1:]:

0 commit comments

Comments
 (0)