Skip to content

Commit 2e30318

Browse files
author
araraonline
committed
Add Parameters and Returns to docstrings
1 parent efb5dc0 commit 2e30318

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

pandas/core/indexes/api.py

+76
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,20 @@ 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 list objects
80+
When intersect=True, do not accept list of lists
81+
intersect: boolean, default False
82+
If True, calculate the intersection between indexes. Otherwise,
83+
calculate the union
84+
sort: boolean, default False
85+
Whether the result index should come out sorted or not
86+
87+
Returns
88+
-------
89+
Index
5990
"""
6091

6192
# TODO: handle index names!
@@ -84,6 +115,16 @@ def _union_indexes(indexes, sort=True):
84115
"""Return the union of indexes
85116
86117
The behavior of sort and names is not consistent.
118+
119+
Parameters
120+
----------
121+
indexes: a list of Index or list objects
122+
sort: boolean, default True
123+
Whether the result index should come out sorted or not
124+
125+
Returns
126+
-------
127+
Index
87128
"""
88129
if len(indexes) == 0:
89130
raise AssertionError('Must have at least 1 Index to union')
@@ -99,6 +140,14 @@ def _unique_indices(inds):
99140
"""Convert indexes to lists and concatenate them, removing duplicates
100141
101142
The final dtype is inferred.
143+
144+
Parameters
145+
----------
146+
inds: a list of Index or list objects
147+
148+
Returns
149+
-------
150+
Index
102151
"""
103152
def conv(i):
104153
if isinstance(i, Index):
@@ -147,6 +196,15 @@ def _sanitize_and_check(indexes):
147196
Lists are sorted and converted to Index
148197
- [Index, Index, ...]: Return ([Index, Index, ...], TYPE)
149198
TYPE = 'special' if at least one special type, 'array' otherwise
199+
200+
Parameters
201+
----------
202+
indexes: a list of Index or list objects
203+
204+
Returns
205+
-------
206+
sanitized_indexes: list of Index or list objects
207+
type: {'list', 'array', 'special'}
150208
"""
151209
kinds = list({type(index) for index in indexes})
152210

@@ -170,6 +228,15 @@ def _get_consensus_names(indexes):
170228
171229
If there's exactly one non-empty 'names', return this,
172230
otherwise, return empty.
231+
232+
Parameters
233+
----------
234+
indexes: a list of index objects
235+
236+
Returns
237+
-------
238+
list
239+
A list representing the consensus 'names' found
173240
"""
174241

175242
# find the non-none names, need to tupleify to make
@@ -183,6 +250,15 @@ def _get_consensus_names(indexes):
183250

184251
def _all_indexes_same(indexes):
185252
"""Determine if all indexes contain the same elements
253+
254+
Parameters
255+
----------
256+
indexes: a list of Index objects
257+
258+
Returns
259+
-------
260+
boolean
261+
True if all indexes contain the same elements, False otherwise
186262
"""
187263
first = indexes[0]
188264
for index in indexes[1:]:

0 commit comments

Comments
 (0)