hyb
2026-01-09 4cb426cb3ae31e772a09d4ade5b2f0242aaeefa0
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
Ë
nñúh)Dãó—dZddlmZddlZddlmZmZddlmZm    Z    m
Z
m Z m Z ddl Z ddlmZddlZddlmZmZmZmZmZddlZddlZddlmZdd    lmZdd
lmZdd l m!Z!m"Z"dd l#m$Z$m%Z%m&Z&m'Z'dd l(m)Z)erddl*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1d„Z2d„Z3dAd„Z4d„Z5d„Z6dBd„Z7dBd„Z8dBd„Z9dBd„Z:dCd„Z;e    dD                    dEd„«Z<edDdFd„«Z<dGdFd„Z<    dG                    dHd„Z=d„Z>dId„Z?dBd „Z@dBd!„ZAdJd"„ZBdKd#„ZCd$„ZDd%„ZEd&„ZFedLd'„«ZGe                dMd(„«ZGdGdNd)„ZG                dOd*„ZHd+„ZI                dPd,„ZJe j–    dQ                    dRd-„«ZLdSd.„ZMejœejœejžej j¢ej¤ej¦j¢iZTejœd/ejžd0ej¤d1iZUiejœd2“ejžd3“ej¤d4“ej¬d5“ej®d6“ejœd2“ej°d2“ej²d7“ej´d7“ej¶d8“ej¸d8“ejºd9“ej¼d9“ej¾d:“ejÀd:“ejÂd;“ejÄd;“ejžd3ejÆd3ej¤d4ejÈd4ejÊd<ejÌd<ejÎd=ejÐd=i¥ZidTd>„Zjd?„ZkdUd@„Zly)Vzh
Misc tools for implementing data structures
 
Note: pandas.core.common is *not* part of the public API.
é)Ú annotationsN)ÚabcÚ defaultdict)Ú
CollectionÚ    GeneratorÚHashableÚIterableÚSequence)Úpartial)Ú TYPE_CHECKINGÚAnyÚCallableÚcastÚoverload)Úlib)Únp_version_gte1p24)Ú'construct_1d_object_array_from_listlike)Ú is_bool_dtypeÚ
is_integer)ÚABCExtensionArrayÚABCIndexÚ ABCMultiIndexÚ    ABCSeries)Úiterable_not_string)Ú AnyArrayLikeÚ    ArrayLikeÚNpDtypeÚ RandomStateÚT)ÚIndexc#ódK—|D]%}t|«rt|«Ed{–—†Œ"|–—Œ'y7Œ ­w)a
    Flatten an arbitrarily nested sequence.
 
    Parameters
    ----------
    line : sequence
        The non string sequence to flatten
 
    Notes
    -----
    This doesn't consider strings sequences.
 
    Returns
    -------
    flattened : generator
    N)rÚflatten)ÚlineÚelements  úEH:\Change_password\venv_build\Lib\site-packages\pandas/core/common.pyr"r">s5èø€ð"òˆÜ ˜wÔ 'ܘwÓ'× 'Ñ 'à‹Mñ    à 'ús ‚0¡.¢ 0có~—|dj}|ddD]}    |j|k7rd}Œ|S#t$rd}YŒ&wxYw)Nré)ÚnameÚ
ValueError)Úobjsr(Úobjs   r%Úconsensus_name_attrr,VsX€Ø ‰7<‰<€DؐABˆxòˆð    Øx‰x˜4ÒØøðð €Køôò    ØŠDð    ús ™.® <»<có—t|ttjtt
f«r”t|t «s„|jtjk(rPtj|«}tj|«s%d}tj|d¬«r t|«‚yyt|j«ryyt|t«r?t|«dkDr1t!|«tur t|«}tj"|«Sy)aË
    Check whether `key` is a valid boolean indexer.
 
    Parameters
    ----------
    key : Any
        Only list-likes may be considered boolean indexers.
        All other types are not considered a boolean indexer.
        For array-like input, boolean ndarrays or ExtensionArrays
        with ``_is_boolean`` set are considered boolean indexers.
 
    Returns
    -------
    bool
        Whether `key` is a valid boolean indexer.
 
    Raises
    ------
    ValueError
        When the array is an object-dtype ndarray or ExtensionArray
        and contains missing values.
 
    See Also
    --------
    check_array_indexer : Check that `key` is a valid array to index,
        and convert to an ndarray.
    z=Cannot mask with non-boolean array containing NA / NaN valuesT)ÚskipnaFr)Ú
isinstancerÚnpÚndarrayrrrÚdtypeÚobject_ÚasarrayrÚ is_bool_arrayr)rÚlistÚlenÚtypeÚ is_bool_list)ÚkeyÚ    key_arrayÚna_msgs   r%Úis_bool_indexerr=asЀô8Ø ŒiœŸ™¤XÔ/@Ð Aô䘜mÔ,Ø 9‰9œŸ
™
Ò "ÜŸ
™
 3›ˆIä×$Ñ$ YÔ/ØXÜ×$Ñ$ Y°tÕ<ô% VÓ,Ð,ØØÜ ˜3Ÿ9™9Ô %Øð ô
CœÔ    ä ˆs‹8aŠ<ܐC‹y¤Ñ$ä˜3“iÜ×#Ñ# CÓ(Ð (à ócóf—tj|«r|j«r td«‚|S)z®
    Disallow indexing with a float key, even if that key is a round number.
 
    Parameters
    ----------
    val : scalar
 
    Returns
    -------
    outval : scalar
    zYIndexing with a float is no longer supported. Manually convert to an integer key instead.)rÚis_floatrÚ
IndexError)Úvals r%Úcast_scalar_indexerrC˜s2€ô ‡||CÔ˜SŸ^™^Ô-Üð )ó
ð    
ð
€Jr>có—d„|D«S)zL
    Returns a generator consisting of the arguments that are not None.
    c3ó&K—|]    }|€Œ|–—Œ y­w©N©©Ú.0Úargs  r%ú    <genexpr>znot_none.<locals>.<genexpr>²sèø€Ò 3C 3¡?ŒCÑ 3ùs‚ŠrG©Úargss r%Únot_nonerN®s€ñ 4˜4Ô 3Ð3r>có&—td„|D««S)z?
    Returns a boolean indicating if any argument is None.
    c3ó$K—|]}|du–—Œ
y­wrFrGrHs  r%rKzany_none.<locals>.<genexpr>¹óèø€Ò+˜sˆsdŒ{Ñ+ùó‚©ÚanyrLs r%Úany_nonerUµó€ô Ñ+ dÔ+Ó +Ð+r>có&—td„|D««S)zA
    Returns a boolean indicating if all arguments are None.
    c3ó$K—|]}|du–—Œ
y­wrFrGrHs  r%rKzall_none.<locals>.<genexpr>ÀrQrR©ÚallrLs r%Úall_noner[¼rVr>có&—td„|D««S)zC
    Returns a boolean indicating if any argument is not None.
    c3ó$K—|]}|du–—Œ
y­wrFrGrHs  r%rKzany_not_none.<locals>.<genexpr>Çóèø€Ò/ 3ˆs˜$ŒÑ/ùrRrSrLs r%Ú any_not_noner_Ãó€ô Ñ/¨$Ô/Ó /Ð/r>có&—td„|D««S)zE
    Returns a boolean indicating if all arguments are not None.
    c3ó$K—|]}|du–—Œ
y­wrFrGrHs  r%rKzall_not_none.<locals>.<genexpr>Îr^rRrYrLs r%Ú all_not_nonercÊr`r>có&—td„|D««S)z;
    Returns the count of arguments that are not None.
    c3ó$K—|]}|du–—Œ
y­wrFrG)rIÚxs  r%rKz!count_not_none.<locals>.<genexpr>Õsèø€Ò+ ˆq˜Œ}Ñ+ùrR)ÚsumrLs r%Úcount_not_nonerhÑrVr>có—yrFrG©Úvaluesr2s  r%Úasarray_tuplesaferlØs€ðr>có—yrFrGrjs  r%rlrlâó€àr>có.—t|ttf«st|d«s t|«}n8t|t«r |j
St|t «r |j
St|t«r#|tjtfvr t|«S    tj«5ts$tjdtj«tj ||¬«}ddd«t%j&j(t*«rtj |t¬«}|j,dk(r#|Dcgc] }t|«‘Œ}}t|«}|S#1swYŒ|xYw#t"$rt|«cYSwxYwcc}w)NÚ    __array__Úignore©r2é)r/r6ÚtupleÚhasattrrÚ_valuesrr0r3ÚobjectrÚwarningsÚcatch_warningsrÚ simplefilterÚVisibleDeprecationWarningr4r)Ú
issubclassr2r8ÚstrÚndim)rkr2Úresultrfs    r%rlrlçs7€Ü v¤¤e˜}Ô -´¸ÀÔ1Mܐf“‰Ü    FœHÔ    %؏~‰~ÐÜ    FœIÔ    &؏~‰~Ðä&œ$Ô E¬b¯j©j¼&Ð-AÑ$AÜ6°vÓ>Ð>ð ?Ü × $Ñ $Ó &ñ    5å%Ü×%Ñ% h´×0LÑ0LÔMÜ—Z‘Z ¨eÔ4ˆF÷        5ô&—,‘,×#Ñ#¤SÔ)Ü—‘˜F¬&Ô1ˆà ‡{{aÒà$*Ö+˜q”%˜•(Ð+ˆÐ+Ü8¸Ó@ˆà €M÷)    5ð    5ûô
ò?ô
7°vÓ>Ò>ð ?üò,s1ÂE8Â/AE,Ã1E8Å FÅ,E5Å1E8Å8FÆFcóΗt|ttf«r|g}t|ttj
f«s     t|«}t||¬«}|S#t $r|g}YŒwxYw)zë
    Transform label or iterable of labels to array, for use in Index.
 
    Parameters
    ----------
    dtype : dtype
        If specified, use as dtype of the resulting array, otherwise infer.
 
    Returns
    -------
    array
    rr)r/r}rtr6r0r1Ú    TypeErrorrl)Úlabelsr2s  r%Úindex_labels_to_arrayrƒ
se€ô&œ3¤˜,Ô'ؐˆä fœt¤R§Z¡ZÐ0Ô 1ð    Ü˜&“\ˆFô˜v¨UÔ 3€Fà €Møô ò    ØXŠFð    ús» AÁ A$Á#A$có<—|t|ttf«s|gS|SrF)r/rtr6©r+s r%Úmaybe_make_listr†'s €Ø
€œz¨#´´t¨}Ô=؈uˆ Ø €Jr>có¤—t|tj«r%t|tj«s t    |«St t |«}|S)zB
    If obj is Iterable but not list-like, consume into list.
    )r/rr    ÚSizedr6rrr…s r%Úmaybe_iterable_to_listr‰-s:€ô#”s—|‘|Ô$¬Z¸¼S¿Y¹YÔ-GܐC‹yÐÜ
Œz˜3Ó
€CØ €Jr>có‚—t|t«xr.|jduxr|jduxr|jduS)z
    We have a null slice.
    N©r/ÚsliceÚstartÚstopÚstepr…s r%Ú is_null_slicer7sH€ô
    3œÓò    Ø I‰I˜Ð ò    à H‰H˜Ð ò    ð H‰H˜Ð ð    r>có˜—t|t«xr9|jduxr)|jduxr|j|jk(S)z>
    We have an empty slice, e.g. no values are selected.
    N)r/rŒrrŽr…s r%Úis_empty_slicer’CsL€ô
    3œÓò    "Ø I‰I˜TÐ !ò    "à H‰H˜DÐ  ò    "ð I‰I˜Ÿ™Ñ !ð    r>cód—|Dcgc] }t|t«xr t|« ‘Œ"c}Scc}w)zX
    Find non-trivial slices in "line": return a list of booleans with same length.
    )r/rŒr)r#Úks  r%Úis_true_slicesr•Os1€ðDHÖ H¸aŒJqœ%Ó  Ò 9¬°qÓ)9Ð%9Ñ 9Ò HÐHùÒ Hs…%-có†—t|t«xr0|jdk(xr|j|k(xr|jduS)z&
    We have a full length slice.
    rNr‹)r+r#s  r%Ú is_full_slicer—WsG€ô
    3œÓò    Ø I‰I˜‰Nò    à H‰H˜Ñ ò    ð H‰H˜Ð ð    r>có¾—t|d«r t|d«St|t«rt    |j
«St |«rt|«jSy)NÚ__name__)    ruÚgetattrr/r Úget_callable_nameÚfuncÚcallabler8r™r…s r%r›r›csN€äˆsJÔܐs˜JÓ'Ð'ä#”wÔÜ  §¡Ó*Ð*䐄}ܐC‹y×!Ñ!Ð!ð
r>c ó.—t|«r    ||fi|¤ŽS|S)zØ
    Evaluate possibly callable input using obj and kwargs if it is callable,
    otherwise return as it is.
 
    Parameters
    ----------
    maybe_callable : possibly a callable
    obj : NDFrame
    **kwargs
    )r)Úmaybe_callabler+Úkwargss   r%Úapply_if_callabler¡ts"€ôÔÙ˜cÑ, VÑ,Ð,à Ðr>có—tj|«s5t|t«rt    t|j
«St |«}t|tj«std|›«‚|tk(r td«‚|S)a
    Helper function to standardize a supplied mapping.
 
    Parameters
    ----------
    into : instance or subclass of collections.abc.Mapping
        Must be a class, an initialized collections.defaultdict,
        or an instance of a collections.abc.Mapping subclass.
 
    Returns
    -------
    mapping : a collections.abc.Mapping subclass or other constructor
        a callable object that can accept an iterator to create
        the desired Mapping.
 
    See Also
    --------
    DataFrame.to_dict
    Series.to_dict
    zunsupported type: z/to_dict() only accepts initialized defaultdicts) ÚinspectÚisclassr/rr Údefault_factoryr8r|rÚMappingr)Úintos r%Ústandardize_mappingr¨…sp€ô* ?‰?˜4Ô  Ü dœKÔ (Üœ;¨×(<Ñ(<Ó=Ð =ܐD‹zˆÜ dœCŸK™KÔ (ÜÐ,¨T¨FÐ3Ó4Ð4Ø Œ{ÒÜÐIÓJÐJØ €Kr>có—yrFrG©Ústates r%Ú random_stater¬¥rnr>có—yrFrGrªs r%r¬r¬ªs€ðr>có—t|«s4t|tjtjj
f«rtjj |«St|tjj «r|St|tjj«r|S|€tjStd«‚)aq
    Helper function for processing random_state arguments.
 
    Parameters
    ----------
    state : int, array-like, BitGenerator, Generator, np.random.RandomState, None.
        If receives an int, array-like, or BitGenerator, passes to
        np.random.RandomState() as seed.
        If receives an np.random RandomState or Generator, just returns that unchanged.
        If receives `None`, returns np.random.
        If receives anything else, raises an informative ValueError.
 
        Default None.
 
    Returns
    -------
    np.random.RandomState or np.random.Generator. If state is None, returns np.random
 
    zdrandom_state must be an integer, array-like, a BitGenerator, Generator, a numpy RandomState, or None)    rr/r0r1ÚrandomÚ BitGeneratorrrr)rªs r%r¬r¬±s€ô(%ÔœJ u¬r¯z©z¼2¿9¹9×;QÑ;QÐ.RÔS܏y‰y×$Ñ$ UÓ+Ð+Ü    Eœ2Ÿ9™9×0Ñ0Ô    1؈ Ü    Eœ2Ÿ9™9×.Ñ.Ô    /؈ Ø    ˆÜy‰yÐäð +ó
ð    
r>có†—t|t«r&|\}}||vr|›d}t|«‚|||<||i|¤ŽS||g|¢­i|¤ŽS)as
    Apply a function ``func`` to object ``obj`` either by passing obj as the
    first argument to the function or, in the case that the func is a tuple,
    interpret the first element of the tuple as a function and pass the obj to
    that function as a keyword argument whose key is the value of the second
    element of the tuple.
 
    Parameters
    ----------
    func : callable or tuple of (callable, str)
        Function to apply to this object or, alternatively, a
        ``(callable, data_keyword)`` tuple where ``data_keyword`` is a
        string indicating the keyword of ``callable`` that expects the
        object.
    *args : iterable, optional
        Positional arguments passed into ``func``.
    **kwargs : dict, optional
        A dictionary of keyword arguments passed into ``func``.
 
    Returns
    -------
    object : the return type of ``func``.
    z/ is both the pipe target and a keyword argument)r/rtr))r+rœrMr ÚtargetÚmsgs      r%Úpiper´Ôsd€ô4$œÔ؉ ˆˆfØ VÑ ØHÐKÐLˆCܘS“/Ð !؈ˆv‰ÙTÐ$˜VÑ$Ð$áCÐ)˜$Ò) &Ñ)Ð)r>cóV‡—ˆfd„}t‰tjtf«r|S‰S)zv
    Returns a function that will map names/labels, dependent if mapper
    is a dict, Series or just a function.
    có•—|‰vr‰|S|SrFrG)rfÚmappers €r%Úfzget_rename_function.<locals>.fÿsø€Ø ‰;ؘ!‘9Ð àˆHr>)r/rr¦r)r·r¸s` r%Úget_rename_functionr¹ùs'ø€ô ô ˜6¤C§K¡K´Ð#;Ô<ˆ1ÐHÀ&ÐHr>cóԗt|ttjtt
t f«r|St|tj«rt|t«s t|«S|gS)z¤
    Convert list-like or scalar input to list-like. List, numpy and pandas array-like
    inputs are returned unmodified whereas others are converted to list.
    )
r/r6r0r1rrrrr    r})rks r%Úconvert_to_list_liker»sK€ô&œ4¤§¡¬X´yÔBSÐTÔU؈ Ü    FœCŸL™LÔ    )´*¸VÄSÔ2IܐF‹|Ðà ˆ8€Or>c#ó–K—|rt||«}t|||«    |–—|rt||«yy#|rt||«wwxYw­w)aØ
    Temporarily set attribute on an object.
 
    Parameters
    ----------
    obj : object
        Object whose attribute will be modified.
    attr : str
        Attribute to modify.
    value : Any
        Value to temporarily set attribute to.
    condition : bool, default True
        Whether to set the attribute. Provided in order to not have to
        conditionally use this context manager.
 
    Yields
    ------
    object : obj with modified attribute.
    N)ršÚsetattr)r+ÚattrÚvalueÚ    conditionÚ    old_values     r%Ú temp_setattrrÂsUèø€ñ.ܘC Ó&ˆ    ÜT˜5Ô!ð*ØŠ    á Ü C˜˜yÕ )ð ø‰9Ü C˜˜yÕ )ð üs‚A    Ÿ4£A    ´AÁA    cóz—t|«t|«k7r$tdt|«›dt|«›d«‚y)zC
    Check the length of data matches the length of the index.
    zLength of values (z") does not match length of index (ú)N)r7r))ÚdataÚindexs  r%Úrequire_length_matchrÇ8sI€ô ˆ4ƒy”C˜“JÒÜð ܐD“    ˆ{ðäE“
ˆ|˜1ð ó
ð    
ðr>znp.sumznp.maximum.reduceznp.minimum.reducergÚmaxÚminrZrTÚmeanÚprodÚstdÚvarÚmedianÚcumprodÚcumsumcó,—tj|«S)zH
    if we define an internal function for this argument, return it
    )Ú _cython_tableÚget©rJs r%Úget_cython_funcrÕrs€ô × Ñ ˜SÓ !Ð!r>có.—tj||«S)zd
    if we define a builtin function for this argument, return it,
    otherwise return the arg
    )Ú_builtin_tablerÓrÔs r%Úis_builtin_funcrØys€ô
× Ñ ˜c 3Ó 'Ð'r>cóX—t|«Dcgc]\}}|€d|›n|‘Œc}}Scc}}w)a,
    If a name is missing then replace it by level_n, where n is the count
 
    .. versionadded:: 1.4.0
 
    Parameters
    ----------
    names : list-like
        list of column names or None values.
 
    Returns
    -------
    list
        list of column names with the None values replaced.
    Úlevel_)Ú    enumerate)ÚnamesÚir(s   r%Úfill_missing_namesrށs2€ô CLÈEÓBR× S±w°q¸$˜D˜LˆfQC‰L¨dÑ 2Ó SÐSùÓ Ss&)r:r ÚreturnÚbool)rßrà)rßÚint).)rkzArrayLike | list | tuple | zipr2úNpDtype | Nonerßú
np.ndarray)rkr    r2rârßrrF)r‚znp.ndarray | Iterabler2rârßrã)r+zIterable[T] | TrßzCollection[T] | T)rßz
list[bool])r#rárßrà)r«únp.random.Generatorrßrä)r«zHint | np.ndarray | np.random.BitGenerator | np.random.RandomState | Nonerßznp.random.RandomState)r«zRandomState | None)rœz/Callable[..., T] | tuple[Callable[..., T], str]rßr)rkz"Hashable | Iterable | AnyArrayLikerßzlist | AnyArrayLike)T)r¾r}rÀràrßzGenerator[None, None, None])rÆr rßÚNone)rJrrßz
str | None)rÜzSequence[Hashable | None]rßzlist[Hashable])mÚ__doc__Ú
__future__rÚbuiltinsÚ collectionsrrÚcollections.abcrrrr    r
Ú
contextlibÚ    functoolsr r£Útypingr r rrrrxÚnumpyr0Ú pandas._libsrÚpandas.compat.numpyrÚpandas.core.dtypes.castrÚpandas.core.dtypes.commonrrÚpandas.core.dtypes.genericrrrrÚpandas.core.dtypes.inferencerÚpandas._typingrrrrrÚpandasr r"r,r=rCrNrUr[r_rcrhrlrƒr†r‰rr’r•r—r›r¡r¨r¬r´r¹r»ÚcontextmanagerrÂrÇrgrÈÚmaximumÚreducerÉÚminimumr×Ú_builtin_table_aliasrZrTÚnansumrÊÚnanmeanrËÚnanprodrÌÚnanstdrÍÚnanvarrÎÚ    nanmedianÚnanmaxÚnanminrÏÚ
nancumprodrÐÚ    nancumsumrÒrÕrØrÞrGr>r%ú<module>rsºðñõ
#ã÷÷õóÝÛ÷õóãåÝ2åK÷÷óõ =á÷õõòò0ó4ònò,4ó,ó,ó0ó0ó,ð
àDGðØ *ðØ3Aðàòó
ðð
óó
ðô ðH<@ðØ !ðØ*8ðàóò:ó ó    ó    óIó    òò"ò"ð@
òó
ðð
ðØ Sðàòó
ðô  
ðF"*Ø>ð"*àó"*òJ Ið Ø .ð àó ð ×Ñà-1ð*Øð*Ø&*ð*à ò*óð*ó@
 
ð" ‡LL"—&‘&Ø ‡LL"—*‘*×#Ñ#Ø ‡LL"—*‘*×#Ñ#ð€ð ‡LL(Ø ‡LLÐ%Ø ‡LLÐ%ðÐð Ø ‡LL%ðà ‡LL%ðð ‡LL%ðð‡FFˆEð    ð
‡FFˆEð ð ‡FFˆEð ð‡IIˆuðð‡GGˆVðð‡JJðð‡GGˆVðð‡JJðð‡FFˆEðð‡IIˆuðð‡FFˆEðð‡IIˆuðð ‡IIˆxð!ð"‡LL(ð#ð$‡FFˆE؇IIˆu؇FFˆE؇IIˆu؇JJ    Ø‡MM9؇IIˆx؇LL(ñ3€ ó:"ò(ôTr>