MCPcopy
hub / github.com/pandas-dev/pandas / _get_combined_index

Function _get_combined_index

pandas/core/indexes/api.py:109–148  ·  view source on GitHub ↗

Return the union or intersection of indexes. Parameters ---------- indexes : list of Index or list objects When intersect=True, do not accept list of lists. intersect : bool, default False If True, calculate the intersection between indexes. Otherwise, c

(
    indexes: list[Index],
    intersect: bool = False,
    sort: bool | lib.NoDefault = False,
)

Source from the content-addressed store, hash-verified

107
108
109def _get_combined_index(
110 indexes: list[Index],
111 intersect: bool = False,
112 sort: bool | lib.NoDefault = False,
113) -> Index:
114 """
115 Return the union or intersection of indexes.
116
117 Parameters
118 ----------
119 indexes : list of Index or list objects
120 When intersect=True, do not accept list of lists.
121 intersect : bool, default False
122 If True, calculate the intersection between indexes. Otherwise,
123 calculate the union.
124 sort : bool, default False
125 Whether the result index should come out sorted or not. NoDefault
126 used for deprecation of GH#57335
127
128 Returns
129 -------
130 Index
131 """
132 # TODO: handle index names!
133 indexes = _get_distinct_objs(indexes)
134 if len(indexes) == 0:
135 index: Index = default_index(0)
136 elif len(indexes) == 1:
137 index = indexes[0]
138 elif intersect:
139 index = indexes[0]
140 for other in indexes[1:]:
141 index = index.intersection(other)
142 else:
143 index = union_indexes(indexes, sort=sort if sort is lib.no_default else False)
144 index = ensure_index(index)
145
146 if sort and sort is not lib.no_default:
147 index = safe_sort_index(index)
148 return index
149
150
151def safe_sort_index(index: Index) -> Index:

Callers 2

get_objs_combined_axisFunction · 0.85

Calls 6

ensure_indexFunction · 0.90
_get_distinct_objsFunction · 0.85
default_indexFunction · 0.85
union_indexesFunction · 0.85
safe_sort_indexFunction · 0.85
intersectionMethod · 0.80

Tested by 1