
    Mh)D                    b   S r SSKJr  SSKrSSKJrJr  SSKJrJ	r	J
r
JrJr  SSKrSSKJr  SSKrSSKJrJrJrJrJr  SSKrSSKrSSKJr  SS	KJr  SS
KJr  SSK J!r!J"r"  SSK#J$r$J%r%J&r&J'r'  SSK(J)r)  \(       a  SSK*J+r+J,r,J-r-J.r.J/r/  SSK0J1r1  S r2S r3SAS jr4S r5S r6SBS jr7SBS jr8SBS jr9SBS jr:SCS jr;\ SD     SES jj5       r<\SDSFS jj5       r<SGSFS jjr< SG     SHS jjr=S r>SIS jr?SBS  jr@SBS! jrASJS" jrBSKS# jrCS$ rDS% rES& rF\SLS' j5       rG\    SMS( j5       rGSGSNS) jjrG    SOS* jrHS+ rI    SPS, jrJ\R                   SQ     SRS- jj5       rLSSS. jrM\R                  \R                  \R                  \R                  R                  \R                  \R                  R                  0rT\R                  S/\R                  S0\R                  S10rU0 \R                  S2_\R                  S3_\R                  S4_\R                  S5_\R                  S6_\R                  S2_\R                  S2_\R                  S7_\R                  S7_\R                  S8_\R                  S8_\R                  S9_\R                  S9_\R                  S:_\R                  S:_\R                  S;_\R                  S;_\R                  S3\R                  S3\R                  S4\R                  S4\R                  S<\R                  S<\R                  S=\R                  S=0EriSTS> jrjS? rkSUS@ jrlg)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              #  t   #    U  H,  n[        U5      (       a  [        U5       Sh  vN   M(  Uv   M.     g N7f)z
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     D/var/www/html/env/lib/python3.13/site-packages/pandas/core/common.pyr"   r"   >   s2     " w''w'''M	 's   $868c                    U S   R                   nU SS   H  n UR                   U:w  a  S nM  M     U$ ! [         a    S n M-  f = f)Nr      )name
ValueError)objsr(   objs      r%   consensus_name_attrr,   V   sW    7<<DABx	xx4    K  	D	s   3AAc                d   [        U [        [        R                  [        [
        45      (       a  [        U [        5      (       d  U R                  [        R                  :X  aZ  [        R                  " U 5      n[        R                  " U5      (       d(  Sn[        R                  " USS9(       a  [        U5      egg[        U R                  5      (       a  g g[        U [        5      (       aB  [        U 5      S:  a3  [!        U 5      [        La  [        U 5      n [        R"                  " U 5      $ g)as  
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ndarrayr   r   r   dtypeobject_asarrayr   is_bool_arrayr)   r   listlentypeis_bool_list)key	key_arrayna_msgs      r%   is_bool_indexerr=   a   s    8 iX/@A m,,99

"

3I$$Y//X$$Yt< %V,,399%% &  
C		s8a<Cy$3i##C((    c                |    [         R                  " U 5      (       a   U R                  5       (       a  [        S5      eU $ )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      s8     ||CS^^--)
 	

 Jr>   c                     S U  5       $ )zD
Returns a generator consisting of the arguments that are not None.
c              3  .   #    U  H  oc  M  Uv   M     g 7fN .0args     r%   	<genexpr>not_none.<locals>.<genexpr>   s     34CCC4s   	rG   argss    r%   not_nonerO      s     4433r>   c                 &    [        S U  5       5      $ )z7
Returns a boolean indicating if any argument is None.
c              3  (   #    U  H  oS L v   M
     g 7frF   rG   rH   s     r%   rK   any_none.<locals>.<genexpr>        +dsd{d   anyrM   s    r%   any_nonerW           +d+++r>   c                 &    [        S U  5       5      $ )z9
Returns a boolean indicating if all arguments are None.
c              3  (   #    U  H  oS L v   M
     g 7frF   rG   rH   s     r%   rK   all_none.<locals>.<genexpr>   rS   rT   allrM   s    r%   all_noner^      rX   r>   c                 &    [        S U  5       5      $ )z;
Returns a boolean indicating if any argument is not None.
c              3  (   #    U  H  oS Lv   M
     g 7frF   rG   rH   s     r%   rK   any_not_none.<locals>.<genexpr>        /$3$$rT   rU   rM   s    r%   any_not_nonerc           /$///r>   c                 &    [        S U  5       5      $ )z=
Returns a boolean indicating if all arguments are not None.
c              3  (   #    U  H  oS Lv   M
     g 7frF   rG   rH   s     r%   rK   all_not_none.<locals>.<genexpr>   rb   rT   r\   rM   s    r%   all_not_nonerh      rd   r>   c                 &    [        S U  5       5      $ )z3
Returns the count of arguments that are not None.
c              3  (   #    U  H  oS Lv   M
     g 7frF   rG   )rI   xs     r%   rK   !count_not_none.<locals>.<genexpr>   s     +d}drT   )sumrM   s    r%   count_not_nonern      rX   r>   c                    g rF   rG   valuesr2   s     r%   asarray_tuplesaferr      s     r>   c                    g rF   rG   rp   s     r%   rr   rr          r>   c                   [        U [        [        45      (       d  [        U S5      (       d  [        U 5      n OB[        U [        5      (       a  U R
                  $ [        U [        5      (       a  U R
                  $ [        U [        5      (       a%  U[        R                  [        4;   a  [        U 5      $  [        R                  " 5          [        (       d%  [        R                  " S[        R                  5        [        R                   " XS9nS S S 5        [%        WR&                  R(                  [*        5      (       a  [        R                   " U [        S9nUR,                  S:X  a&  U  Vs/ s H  n[        U5      PM     n n[        U 5      nU$ ! , (       d  f       N= f! ["         a    [        U 5      s $ f = fs  snf )N	__array__ignorer2      )r/   r6   tuplehasattrr   _valuesr   r0   r3   objectr   warningscatch_warningsr   simplefilterVisibleDeprecationWarningr4   r)   
issubclassr2   r8   strndim)rq   r2   resultrk   s       r%   rr   rr      sD   ve}--1M1Mf	FH	%	%~~	FI	&	&~~&$Ebjj&-A$A6v>>?$$&%%%%h0L0LMZZ4F	 ' &,,##S))F&1{{a$*+Fq%(F+8@M) '&
  ?
 7v>>? ,s7   6F# AFF# .F>
F F#  F# #F;:F;c                    [        U [        [        45      (       a  U /n [        U [        [        R
                  45      (       d   [        U 5      n [        XS9n U $ ! [         a    U /n  Nf = f)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
rx   )r/   r   rz   r6   r0   r1   	TypeErrorrr   )labelsr2   s     r%   index_labels_to_arrayr   
  si     &3,''ftRZZ011	&\F v3FM  	XF	s   A A+*A+c                H    U b  [        U [        [        45      (       d  U /$ U $ rF   )r/   rz   r6   r+   s    r%   maybe_make_listr   '  s#    
z#t}==uJr>   c                    [        U [        R                  5      (       a*  [        U [        R                  5      (       d  [	        U 5      $ [        [        U 5      n U $ )z:
If obj is Iterable but not list-like, consume into list.
)r/   r   r	   Sizedr6   r   r   r   s    r%   maybe_iterable_to_listr   -  s@     #s||$$ZSYY-G-GCy
z3
CJr>   c                    [        U [        5      =(       a8    U R                  SL =(       a#    U R                  SL =(       a    U R                  SL $ )z
We have a null slice.
Nr/   slicestartstopstepr   s    r%   is_null_slicer   7  sH    
 	3 	II	HH	 HH	r>   c                    [        U [        5      =(       aC    U R                  SL=(       a.    U R                  SL=(       a    U R                  U R                  :H  $ )z6
We have an empty slice, e.g. no values are selected.
N)r/   r   r   r   r   s    r%   is_empty_slicer   C  sL    
 	3 	"IIT!	"HHD 	" II!	r>   c                |    U  Vs/ s H*  n[        U[        5      =(       a    [        U5      (       + PM,     sn$ s  snf )zP
Find non-trivial slices in "line": return a list of booleans with same length.
)r/   r   r   )r#   ks     r%   is_true_slicesr   O  s5     DHH4aJq% 9q)9%994HHHs   19c                    [        U [        5      =(       a:    U R                  S:H  =(       a$    U R                  U:H  =(       a    U R                  SL $ )z
We have a full length slice.
r   Nr   )r+   r#   s     r%   is_full_slicer   W  sG    
 	3 	IIN	HH	 HH	r>   c                    [        U S5      (       a  [        U S5      $ [        U [        5      (       a  [	        U R
                  5      $ [        U 5      (       a  [        U 5      R                  $ g )N__name__)	r{   getattrr/   r   get_callable_namefunccallabler8   r   r   s    r%   r   r   c  sV    sJsJ''#w **}}Cy!!!
 r>   c                8    [        U 5      (       a	  U " U40 UD6$ U $ )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   t  s%     c,V,,r>   c                4   [         R                  " U 5      (       d:  [        U [        5      (       a  [	        [        U R
                  5      $ [        U 5      n [        U [        R                  5      (       d  [        SU  35      eU [        :X  a  [        S5      eU $ )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
zunsupported type: z/to_dict() only accepts initialized defaultdicts)inspectisclassr/   r   r   default_factoryr8   r   r   Mappingr   )intos    r%   standardize_mappingr     sy    * ??4  dK((;(<(<==DzdCKK((,TF344{IJJKr>   c                    g rF   rG   states    r%   random_stater     rt   r>   c                    g rF   rG   r   s    r%   r   r     s     r>   c                   [        U 5      (       d9  [        U [        R                  [        R                  R
                  45      (       a  [        R                  R                  U 5      $ [        U [        R                  R                  5      (       a  U $ [        U [        R                  R                  5      (       a  U $ U c  [        R                  $ [        S5      e)a9  
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)	r   r/   r0   r1   randomBitGeneratorr   r   r)   r   s    r%   r   r     s    ( %Jurzz299;Q;Q.RSSyy$$U++	E29900	1	1	E299..	/	/	yy+
 	
r>   c                    [        U[        5      (       a%  Uu  pXC;   a  U S3n[        U5      eXU'   U" U0 UD6$ U" U /UQ70 UD6$ )a#  
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/   rz   r)   )r+   r   rN   r   targetmsgs         r%   piper     sa    4 $HKLCS/!vT$V$$C)$)&))r>   c                b   ^  U 4S jn[        T [        R                  [        45      (       a  U$ T $ )zj
Returns a function that will map names/labels, dependent if mapper
is a dict, Series or just a function.
c                   > U T;   a  TU    $ U $ rF   rG   )rk   mappers    r%   fget_rename_function.<locals>.f  s    ;!9Hr>   )r/   r   r   r   )r   r   s   ` r%   get_rename_functionr     s*     6CKK#;<<1H&Hr>   c                    [        U [        [        R                  [        [
        [        45      (       a  U $ [        U [        R                  5      (       a   [        U [        5      (       d  [        U 5      $ U /$ )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/   r6   r0   r1   r   r   r   r   r	   r   )rq   s    r%   convert_to_list_liker     sT     &4XyBSTUU	FCLL	)	)*VS2I2IF|8Or>   c              #     #    U(       a  [        X5      n[        XU5         U v   U(       a  [        XW5        gg! U(       a  [        XW5        f f = f7f)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     sL     . C&	5!*	Cy) 9Cy) s   A; AAAc                |    [        U 5      [        U5      :w  a$  [        S[        U 5       S[        U5       S35      eg)z;
Check the length of data matches the length of the index.
zLength of values (z") does not match length of index ()N)r7   r)   )dataindexs     r%   require_length_matchr   8  sI     4yCJD	{ E
|1
 	
 r>   znp.sumznp.maximum.reduceznp.minimum.reducerm   maxminr]   rV   meanprodstdvarmediancumprodcumsumc                ,    [         R                  U 5      $ )z@
if we define an internal function for this argument, return it
)_cython_tablegetrJ   s    r%   get_cython_funcr   r  s     S!!r>   c                ,    [         R                  X 5      $ )zX
if we define a builtin function for this argument, return it,
otherwise return the arg
)_builtin_tabler   r   s    r%   is_builtin_funcr   y  s    
 c''r>   c                ^    [        U 5       VVs/ s H  u  pUc  SU 3OUPM     snn$ s  snnf )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     s6      CLEBRSBRwqDLfQCLd2BRSSSs   ))r:   r   returnbool)r   r   )r   int).)rq   zArrayLike | list | tuple | zipr2   NpDtype | Noner   
np.ndarray)rq   r	   r2   r   r   r   rF   )r   znp.ndarray | Iterabler2   r   r   r   )r+   zIterable[T] | Tr   zCollection[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   znp.random.RandomState)r   zRandomState | None)r   z/Callable[..., T] | tuple[Callable[..., T], str]r   r   )rq   z"Hashable | Iterable | AnyArrayLiker   zlist | AnyArrayLike)T)r   r   r   r   r   zGenerator[None, None, None])r   r    r   None)rJ   r   r   z
str | None)r   zSequence[Hashable | None]r   zlist[Hashable])m__doc__
__future__r   builtinscollectionsr   r   collections.abcr   r   r   r	   r
   
contextlib	functoolsr   r   typingr   r   r   r   r   r~   numpyr0   pandas._libsr   pandas.compat.numpyr   pandas.core.dtypes.castr   pandas.core.dtypes.commonr   r   pandas.core.dtypes.genericr   r   r   r   pandas.core.dtypes.inferencer   pandas._typingr   r   r   r   r   pandasr    r"   r,   r=   rC   rO   rW   r^   rc   rh   rn   rr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   contextmanagerr   r   rm   r   maximumreducer   minimumr   _builtin_table_aliasr]   rV   nansumr   nanmeanr   nanprodr   nanstdr   nanvarr   	nanmediannanmaxnanminr   
nancumprodr   	nancumsumr   r   r   r   rG   r>   r%   <module>r     s  
 #          2 K  =  04n,4,,00, 
DG*3A 
 
 
 H <@!*8:		I	""@ 
 
 
S 
 
F"*>"*"*JI. -1**&** * *@

" LL"&&LL"**##LL"**## LL(LL%LL% LL%LL% LL% FFE	
 FFE FFE IIu GGV JJ GGV JJ FFE IIu FFE IIu  IIx!" LL(#$ FFEIIuFFEIIuJJ	MM9IIxLL(3:"(Tr>   