zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
U
¬ý°d(ã@s˜ddlmZddlZddlmZddlZddlmZm    Z    ddl
m Z ddl m Z ddlmZddlmZdd    lmZmZmZmZmZdd
lmZdd lmZdd lmZdd lmZddl m!Z!ddl"m#Z#ddl$m%Z%e &d¡Z'ddddddddddddddd d!d"d#d$gZ(d>d'd(d'd'dd)œd*d„Z)d+d+d,œd-d.„Z*d?d+d'd'd'dd/œd0d1„Z+ddd2œd3d$„Z,d@d4dd5œd6d „Z-d7d8„Z.d'd9œd:d"„Z/d;dd<œd=d#„Z0dS)Aé)Ú annotationsN)Úcast)ÚNaTÚlib)ÚAxis)ÚInvalidIndexError©Úfind_common_type)Ú    safe_sort)ÚIndexÚ
_new_IndexÚ ensure_indexÚensure_index_from_sequencesÚget_unanimous_names)ÚCategoricalIndex)Ú DatetimeIndex)Ú IntervalIndex)Ú
MultiIndex)Ú PeriodIndex)Ú
RangeIndex)ÚTimedeltaIndexzôSorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.
 
To accept the future behavior, pass 'sort=False'.
 
To retain the current behavior and silence the warning, pass 'sort=True'.
r rrrrrrrrr rr rÚget_objs_combined_axisÚ union_indexesrÚall_indexes_sameÚ default_indexÚsafe_sort_indexFTÚboolr)Ú    intersectÚaxisÚsortÚcopyÚreturncs"‡fdd„|Dƒ}t||||dS)añ
    Extract combined index: return intersection or union (depending on the
    value of "intersect") of indexes on given axis, or None if all objects
    lack indexes (e.g. they are numpy arrays).
 
    Parameters
    ----------
    objs : list
        Series or DataFrame objects, may be mix of the two.
    intersect : bool, default False
        If True, calculate the intersection between indexes. Otherwise,
        calculate the union.
    axis : {0 or 'index', 1 or 'outer'}, default 0
        The axis to extract indexes from.
    sort : bool, default True
        Whether the result index should come out sorted or not.
    copy : bool, default False
        If True, return a copy of the combined index.
 
    Returns
    -------
    Index
    csg|]}| ˆ¡‘qS©)Z    _get_axis)Ú.0Úobj©rr"úNd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/indexes/api.pyÚ
<listcomp>^sz*get_objs_combined_axis.<locals>.<listcomp>)rrr )Ú_get_combined_index)Úobjsrrrr Z    obs_idxesr"r%r&rDsz list[Index])r)r!cCs<tƒ}g}|D](}t|ƒ|kr| t|ƒ¡| |¡q|S)z^
    Return a list with distinct elements of "objs" (different ids).
    Preserves order.
    )ÚsetÚidÚaddÚappend)r)ÚidsÚresr$r"r"r&Ú_get_distinct_objsbs  r0)Úindexesrrr r!cCsŽt|ƒ}t|ƒdkrtgƒ}nTt|ƒdkr4|d}n>|r^|d}|dd…D]}| |¡}qLnt|dd}t|ƒ}|r~t|ƒ}|rŠ| ¡}|S)a
    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,
        calculate the union.
    sort : bool, default False
        Whether the result index should come out sorted or not.
    copy : bool, default False
        If True, return a copy of the combined index.
 
    Returns
    -------
    Index
    réNF©r)r0Úlenr Ú intersectionrr rr )r1rrr ÚindexÚotherr"r"r&r(ps  
 
 r()r6r!cCsx|jr
|Sz t|ƒ}Wntk
r*YnJXt|tƒr:|Sttj|ƒ}t|tƒrbtj    ||j
d}nt||j |j d}|S)zª
    Returns the sorted index
 
    We keep the dtypes and the name attributes.
 
    Parameters
    ----------
    index : an Index
 
    Returns
    -------
    Index
    )Únames)ÚnameÚdtype) Zis_monotonic_increasingr
Ú    TypeErrorÚ
isinstancer rÚnpZndarrayrÚ from_tuplesr8r9r:)r6Z array_sortedr"r"r&r s 
 
z bool | None)rr!c sªtˆƒdkrtdƒ‚tˆƒdkrBˆd}t|tƒr>tt|ƒƒ}|Stˆƒ\‰}ddœ‡fdd„ }‡fdd    „}|d
kr*ˆd}d d „ˆDƒ}d d „|Dƒ}t|ƒdt|ƒfkr¶tdƒ‚t|ƒtˆƒkrÔd‰ˆd}n&t|ƒdkrúd‰dd „ˆDƒ‰ˆd}ˆdd…D]}|j|ˆrdndd}q|S|dkr”|ˆƒ}    ˆd‰t    ‡fdd„ˆdd…Dƒƒsn|ˆ|    ƒ‰t
ˆŽd}
|
ˆj krˆ  |
¡‰ˆS|ˆƒ}    |ˆ|    ƒSdS)a)
    Return the union of indexes.
 
    The behavior of sort and names is not consistent.
 
    Parameters
    ----------
    indexes : list of Index or list objects
    sort : bool, default True
        Whether the result index should come out sorted or not.
 
    Returns
    -------
    Index
    rz#Must have at least 1 Index to unionr2r ©r!cs,dd„‰ttj‡fdd„|Dƒˆd|dS)a3
        Convert indexes to lists and concatenate them, removing duplicates.
 
        The final dtype is inferred.
 
        Parameters
        ----------
        inds : list of Index or list objects
        dtype : dtype to set for the resulting Index
 
        Returns
        -------
        Index
        cSst|tƒr| ¡}|S©N)r<r Útolist)Úir"r"r&Úconvìs
z4union_indexes.<locals>._unique_indices.<locals>.convcsg|] }ˆ|ƒ‘qSr"r")r#rB©rCr"r&r'òsz:union_indexes.<locals>._unique_indices.<locals>.<listcomp>r3)r:)r rZfast_unique_multiple_list)Úindsr:r3rDr&Ú_unique_indicesÜs
þz&union_indexes.<locals>._unique_indicescs$dd„ˆDƒ}|rt|ƒ}nd}|S)a
        Finds a common type for the indexes to pass through to resulting index.
 
        Parameters
        ----------
        inds: list of Index or list objects
 
        Returns
        -------
        The common type or None if no indexes were given
        cSsg|]}t|tƒr|j‘qSr")r<r r:)r#Úidxr"r"r&r's
zCunion_indexes.<locals>._find_common_index_dtype.<locals>.<listcomp>Nr)rEZdtypesr:)r1r"r&Ú_find_common_index_dtypeös
 
z/union_indexes.<locals>._find_common_index_dtypeÚspecialcSsg|]}t|tƒr|‘qSr")r<r©r#Úxr"r"r&r' s
z!union_indexes.<locals>.<listcomp>cSsg|]}|jdk    r|‘qSr@)ÚtzrJr"r"r&r's
z0Cannot join tz-naive with tz-aware DatetimeIndexTFcSsg|]}|jtdd‘qS)F)r )ZastypeÚobjectrJr"r"r&r'!sNr3Úarrayc3s|]}ˆ |¡VqdSr@©Úequals)r#r7)r6r"r&Ú    <genexpr>+sz union_indexes.<locals>.<genexpr>) r4ÚAssertionErrorr<Úlistr ÚsortedÚ_sanitize_and_checkr;ÚunionÚallrr9Úrename) r1rÚresultÚkindrFrHZdtisZdti_tzsr7r:r9r")r6r1rr&rÂsJ  
 
 
 
 
 
cCsptdd„|Dƒƒ}t|krHt|ƒdkr@dd„|Dƒ}| t¡n|dfSt|ƒdks\t|krd|dfS|dfSd    S)
aN
    Verify the type of indexes and convert lists to Index.
 
    Cases:
 
    - [list, list, ...]: Return ([list, list, ...], 'list')
    - [list, Index, ...]: Return _sanitize_and_check([Index, Index, ...])
        Lists are sorted and converted to Index.
    - [Index, Index, ...]: Return ([Index, Index, ...], TYPE)
        TYPE = 'special' if at least one special type, 'array' otherwise.
 
    Parameters
    ----------
    indexes : list of Index or list objects
 
    Returns
    -------
    sanitized_indexes : list of Index or list objects
    type : {'list', 'array', 'special'}
    cSsh|] }t|ƒ’qSr")Útype©r#r6r"r"r&Ú    <setcomp>Lsz&_sanitize_and_check.<locals>.<setcomp>r2cSs&g|]}t|tƒstt|ƒƒn|‘qSr")r<r rSrJr"r"r&r'Psz'_sanitize_and_check.<locals>.<listcomp>rSrIrNN)rSr4Úremover )r1Úkindsr"r"r&rU7s ÿ rUr?cs&t|ƒ}t|ƒ‰t‡fdd„|DƒƒS)zî
    Determine if all indexes contain the same elements.
 
    Parameters
    ----------
    indexes : iterable of Index objects
 
    Returns
    -------
    bool
        True if all indexes contain the same elements, False otherwise.
    c3s|]}ˆ |¡VqdSr@rOr\©Úfirstr"r&rQlsz#all_indexes_same.<locals>.<genexpr>)ÚiterÚnextrW)r1Úitrr"r`r&r]s Úint)Únr!cCstd|ƒ}tj|ddS)Nr)r9)ÚrangerZ _simple_new)rfÚrngr"r"r&ros
)FrTF)FFF)T)1Ú
__future__rÚtextwrapÚtypingrÚnumpyr=Z pandas._libsrrZpandas._typingrZ pandas.errorsrZpandas.core.dtypes.castr    Zpandas.core.algorithmsr
Zpandas.core.indexes.baser r r rrZpandas.core.indexes.categoryrZpandas.core.indexes.datetimesrZpandas.core.indexes.intervalrZpandas.core.indexes.multirZpandas.core.indexes.periodrZpandas.core.indexes.rangerZpandas.core.indexes.timedeltasrÚdedentZ    _sort_msgÚ__all__rr0r(rrrUrrr"r"r"r&Ú<module>sl             ÿ íÿü0"u&