@@ -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,19 @@ 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 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
59
89
"""
60
90
61
91
# TODO: handle index names!
@@ -84,6 +114,16 @@ def _union_indexes(indexes, sort=True):
84
114
"""Return the union of indexes
85
115
86
116
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
87
127
"""
88
128
if len (indexes ) == 0 :
89
129
raise AssertionError ('Must have at least 1 Index to union' )
@@ -99,6 +139,14 @@ def _unique_indices(inds):
99
139
"""Convert indexes to lists and concatenate them, removing duplicates
100
140
101
141
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
102
150
"""
103
151
def conv (i ):
104
152
if isinstance (i , Index ):
@@ -147,6 +195,15 @@ def _sanitize_and_check(indexes):
147
195
Lists are sorted and converted to Index
148
196
- [Index, Index, ...]: Return ([Index, Index, ...], TYPE)
149
197
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'}
150
207
"""
151
208
kinds = list ({type (index ) for index in indexes })
152
209
@@ -170,6 +227,15 @@ def _get_consensus_names(indexes):
170
227
171
228
If there's exactly one non-empty 'names', return this,
172
229
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
173
239
"""
174
240
175
241
# find the non-none names, need to tupleify to make
@@ -183,6 +249,15 @@ def _get_consensus_names(indexes):
183
249
184
250
def _all_indexes_same (indexes ):
185
251
"""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
186
261
"""
187
262
first = indexes [0 ]
188
263
for index in indexes [1 :]:
0 commit comments