@@ -47,6 +47,23 @@ def _get_objs_combined_axis(objs, intersect=False, axis=0, sort=True):
47
47
"""Extract combined index: return intersection or union (depending on the
48
48
value of "intersect") of indexes on given axis, or None if all objects
49
49
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
50
67
"""
51
68
obs_idxes = [obj ._get_axis (axis ) for obj in objs
52
69
if hasattr (obj , '_get_axis' )]
@@ -56,6 +73,20 @@ def _get_objs_combined_axis(objs, intersect=False, axis=0, sort=True):
56
73
57
74
def _get_combined_index (indexes , intersect = False , sort = False ):
58
75
"""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
59
90
"""
60
91
61
92
# TODO: handle index names!
@@ -84,6 +115,16 @@ def _union_indexes(indexes, sort=True):
84
115
"""Return the union of indexes
85
116
86
117
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
87
128
"""
88
129
if len (indexes ) == 0 :
89
130
raise AssertionError ('Must have at least 1 Index to union' )
@@ -99,6 +140,14 @@ def _unique_indices(inds):
99
140
"""Convert indexes to lists and concatenate them, removing duplicates
100
141
101
142
The final dtype is inferred.
143
+
144
+ Parameters
145
+ ----------
146
+ inds: a list of Index or list objects
147
+
148
+ Returns
149
+ -------
150
+ Index
102
151
"""
103
152
def conv (i ):
104
153
if isinstance (i , Index ):
@@ -147,6 +196,15 @@ def _sanitize_and_check(indexes):
147
196
Lists are sorted and converted to Index
148
197
- [Index, Index, ...]: Return ([Index, Index, ...], TYPE)
149
198
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'}
150
208
"""
151
209
kinds = list ({type (index ) for index in indexes })
152
210
@@ -170,6 +228,15 @@ def _get_consensus_names(indexes):
170
228
171
229
If there's exactly one non-empty 'names', return this,
172
230
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
173
240
"""
174
241
175
242
# find the non-none names, need to tupleify to make
@@ -183,6 +250,15 @@ def _get_consensus_names(indexes):
183
250
184
251
def _all_indexes_same (indexes ):
185
252
"""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
186
262
"""
187
263
first = indexes [0 ]
188
264
for index in indexes [1 :]:
0 commit comments