+
    Ŝi^F                       R t ^ RIHt ^ RIt^ RIHtHt ^ RIHtH	t	H
t
HtHtHt ^ RIt^ RIHt ^ RIt^ RIt^ RIHtHtHtHtHtHt ^ RIt^ RIHt ^ RIHt ^ R	I H!t!H"t" ^ R
I#H$t$H%t%H&t&H't'H(t( ^ RI)H*t* ^ RI+H,t, ]'       d   ^ RI-H.t.H/t/H0t0H1t1H2t2H3t3 ^ RI4H5t5 R t6R t7R R lt8R t9R t:R R lt;R R lt<R R lt=R R lt>R R lt?]RZR R  ll4       t@]RZR! R" ll4       t@R[R# R$ llt@R[R% R& lltAR' tBR( R) ltCR* R+ ltDR, R- ltER. R/ ltFR0 R1 ltGR2 tHR3 tIR4 tJ]R5 R6 l4       tK]R7 R8 l4       tKR[R9 R: lltK]! R;4      tL]R< R= l4       tM]R> R? l4       tMR@ RA ltMRB tNRC RD ltO]P                  R\RE RF ll4       tQRG RH ltR/ ]P                  RIb]P                  RJb]P                  RKb]P                  RLb]P                  RMb]P                  RIb]P                  RIb]P                  RNb]P                  RNb]P                  ROb]P                  ROb]P                  RPb]P                  RPb]P                  RQb]P                  RQb]P                  RRb]P                  RRb]P                  RJ]P                  RJ]P                  RK]P                  RK]P                  RS]P                  RS]P                  RT]P                  RT/CtiRU RV ltjRW RX ltkRY tlR# )]zh
Misc tools for implementing data structures

Note: pandas.core.common is *not* part of the public API.
)annotationsN)abcdefaultdict)Callable
Collection	GeneratorHashableIterableSequence)partial)TYPE_CHECKINGAnyConcatenateTypeVarcastoverload)lib)'construct_1d_object_array_from_listlike)is_bool_dtype
is_integer)ABCExtensionArrayABCIndexABCMultiIndexABCNumpyExtensionArray	ABCSeries)iterable_not_string)
Expression)AnyArrayLike	ArrayLikeNpDtypePRandomStateT)Indexc              #  x   "   V  F-  p\        V4      '       d   \        V4       Rj  xL
  K)  Vx  K/  	  R#  L5i)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   & [/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/pandas/core/common.pyr%   r%   D   s2     " w''w'''M	 's   %:8:c                    V ^ ,          P                   pV R,           F  p VP                   V8w  d   Rp V# K  	  V#   \         d    Rp  T# i ; i)    :   NNN)name
ValueError)objsr,   objs   &  r(   consensus_name_attrr0   \   si    7<<DBxx	xx4 K    K  	DK	s   =AAc                    V ^8  d   QhRRRR/# )   keyr   returnbool )formats   "r(   __annotate__r8   i   s     5 5 5 5    c                   \        V \        \        P                  \        \
        \        34      '       d   \        V \        4      '       g   V P                  \        P                  8X  db   \        P                  ! V 4      p\        P                  ! V4      '       g.   Rp\        P                  ! VRR7      '       d   \        V4      hR# R# \        V P                  4      '       d   R#  R# \        V \        4      '       dE   \!        V 4      ^ 8  d5   \#        V 4      \        Jd   \        V 4      p \        P$                  ! V 4      # R# )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)skipnaF)
isinstancer   npndarrayr   r   r   r   dtypeobject_asarrayr   is_bool_arrayr-   r   listlentypeis_bool_list)r3   	key_arrayna_msgs   &  r(   is_bool_indexerrI   i   s    8 	BJJ*;=ST  m,,99

"

3I$$Y//X$$Yt<< %V,,399%% &  
C		s8a<Cy$3i##C((r9   c                    \         P                  ! V 4      '       d"   V P                  4       '       d   \        R4      hV # )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_indexerrN      s8     ||CS^^--)
 	

 Jr9   c                     R V  4       # )zD
Returns a generator consisting of the arguments that are not None.
c              3  0   "   T F  qf   K  Vx  K  	  R # 5iNr6   .0args   & r(   	<genexpr>not_none.<locals>.<genexpr>   s     34CCC4s   
r6   argss   *r(   not_nonerY      s     4433r9   c                   V ^8  d   QhRR/# r2   r4   r5   r6   )r7   s   "r(   r8   r8           , ,t ,r9   c                 j    \         ;QJ d    R V  4       F  '       g   K   R# 	  R# ! R V  4       4      # )z7
Returns a boolean indicating if any argument is None.
c              3  (   "   T F  qR J x  K
  	  R # 5irQ   r6   rR   s   & r(   rU   any_none.<locals>.<genexpr>        +dsd{d   TFanyrW   s   *r(   any_nonerd      -     3+d+33+3+3+d+++r9   c                   V ^8  d   QhRR/# r[   r6   )r7   s   "r(   r8   r8      r\   r9   c                 j    \         ;QJ d    R V  4       F  '       d   K   R# 	  R# ! R V  4       4      # )z9
Returns a boolean indicating if all arguments are None.
c              3  (   "   T F  qR J x  K
  	  R # 5irQ   r6   rR   s   & r(   rU   all_none.<locals>.<genexpr>   r`   ra   FTallrW   s   *r(   all_nonerl      re   r9   c                   V ^8  d   QhRR/# r[   r6   )r7   s   "r(   r8   r8           0 04 0r9   c                 j    \         ;QJ d    R V  4       F  '       g   K   R# 	  R# ! R V  4       4      # )z;
Returns a boolean indicating if any argument is not None.
c              3  (   "   T F  qR Jx  K
  	  R # 5irQ   r6   rR   s   & r(   rU   any_not_none.<locals>.<genexpr>        /$3$$ra   TFrb   rW   s   *r(   any_not_noners      -     3/$/33/3/3/$///r9   c                   V ^8  d   QhRR/# r[   r6   )r7   s   "r(   r8   r8      rn   r9   c                 j    \         ;QJ d    R V  4       F  '       d   K   R# 	  R# ! R V  4       4      # )z=
Returns a boolean indicating if all arguments are not None.
c              3  (   "   T F  qR Jx  K
  	  R # 5irQ   r6   rR   s   & r(   rU   all_not_none.<locals>.<genexpr>   rr   ra   FTrj   rW   s   *r(   all_not_nonery      rt   r9   c                   V ^8  d   QhRR/# )r2   r4   intr6   )r7   s   "r(   r8   r8      s     , ,S ,r9   c                 &    \        R V  4       4      # )z3
Returns the count of arguments that are not None.
c              3  (   "   T F  qR Jx  K
  	  R # 5irQ   r6   )rS   xs   & r(   rU   !count_not_none.<locals>.<genexpr>   s     +d}dra   )sumrW   s   *r(   count_not_noner      s     +d+++r9   c               $    V ^8  d   QhRRRRRR/# )r2   valueszArrayLike | list | tuple | zipr?   NpDtype | Noner4   
np.ndarrayr6   )r7   s   "r(   r8   r8      s$      *3Ar9   c                    R # rQ   r6   r   r?   s   &&r(   asarray_tuplesafer      s     r9   c               $    V ^8  d   QhRRRRRR/# r2   r   r	   r?   r   r4   r   r6   )r7   s   "r(   r8   r8      s     V Vh V~ V	 Vr9   c                    R # rQ   r6   r   s   &&r(   r   r      s    SVr9   c               $    V ^8  d   QhRRRRRR/# r   r6   )r7   s   "r(   r8   r8      s!      h ~  r9   c                   \        V \        \        34      '       g   \        V R 4      '       g   \        V 4      p MD\        V \        4      '       d   V P
                  # \        V \        4      '       d   V P
                  # \        V \        4      '       d'   V\        P                  \        39   d   \        V 4      #  \        P                  ! WR7      p\        TP                  P                  \         4      '       d   \        P                  ! T \        R7      pTP"                  ^8X  d&   T  Uu. uF  p\        T4      NK  	  p p\        T 4      pT#   \         d    \        T 4      u # i ; iu upi )	__array__r?   )r<   rC   tuplehasattrr   _valuesr   r=   r@   objectr   rA   r-   
issubclassr?   rE   strndim)r   r?   resultr~   s   &&  r(   r   r      s   ve}--1M1Mf	FH	%	%~~	FI	&	&~~&$Ebjj&-A$A6v>>?F0 &,,##S))F&1{{a$*+Fq%(F+8@M  ?
 7v>>? ,s   <E .E-E*)E*c               $    V ^8  d   QhRRRRRR/# )r2   labelsznp.ndarray | Iterabler?   r   r4   r   r6   )r7   s   "r(   r8   r8     s$      !*8r9   c                    \        V \        \        34      '       d   V .p \        V \        \        P
                  34      '       g    \        V 4      p \        WR7      pV#   \         d    T .p  Li ; i)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
r   )r<   r   r   rC   r=   r>   	TypeErrorr   )r   r?   rlabelss   && r(   index_labels_to_arrayr     si     &3,''ftRZZ011	&\F  4GN  	XF	s   A   A10A1c                L    V e    \        V \        \        34      '       g   V .# V # rQ   )r<   r   rC   r/   s   &r(   maybe_make_listr   +  s#    
z#t}==uJr9   c                    V ^8  d   QhRRRR/# )r2   r/   zIterable[T] | Tr4   zCollection[T] | Tr6   )r7   s   "r(   r8   r8   1  s       4E r9   c                    \        V \        P                  4      '       d,   \        V \        P                  4      '       g   \	        V 4      # \        \        V 4      p V # )z:
If obj is Iterable but not list-like, consume into list.
)r<   r   r	   SizedrC   r   r   r   s   &r(   maybe_iterable_to_listr   1  s@     #s||$$ZSYY-G-GCy
z3
CJr9   c                   V ^8  d   QhRR/# r[   r6   )r7   s   "r(   r8   r8   ;  s     	 	$ 	r9   c                    \        V \        4      ;'       d;    V P                  RJ ;'       d%    V P                  RJ ;'       d    V P                  RJ # )z
We have a null slice.
Nr<   slicestartstopstepr   s   &r(   is_null_slicer   ;  sW    
 	3 	 	II	 	HH	 	 HH	r9   c                   V ^8  d   QhRR/# r[   r6   )r7   s   "r(   r8   r8   G  s     	 	4 	r9   c                    \        V \        4      ;'       dF    V P                  RJ;'       d0    V P                  RJ;'       d    V P                  V P                  8H  # )z6
We have an empty slice, e.g. no values are selected.
N)r<   r   r   r   r   s   &r(   is_empty_slicer   G  s[    
 	3 	" 	"IIT!	" 	"HHD 	" 	" II!	r9   c                    V ^8  d   QhRRRR/# )r2   r&   zabc.Iterabler4   zabc.Generator[bool, None, None]r6   )r7   s   "r(   r8   r8   S  s     < < <*I <r9   c              #  t   "   V  F-  p\        V\        4      ;'       d    \        V4      '       * x  K/  	  R# 5i)z3
Find non-trivial slices in "line": yields a bool.
N)r<   r   r   )r&   ks   & r(   is_true_slicesr   S  s.      E";;=+;';; s   88c                    V ^8  d   QhRRRR/# )r2   r&   r{   r4   r5   r6   )r7   s   "r(   r8   r8   \  s     	 	S 	T 	r9   c                    \        V \        4      ;'       d=    V P                  ^ 8H  ;'       d&    V P                  V8H  ;'       d    V P                  RJ # )z
We have a full length slice.
Nr   )r/   r&   s   &&r(   is_full_slicer   \  sV    
 	3 	 	IIN	 	HH	 	 HH	r9   c                    \        V R 4      '       d   V P                  # \        V \        4      '       d   \	        V P
                  4      # \        V 4      '       d   \        V 4      P                  # R# )__name__N)r   r   r<   r   get_callable_namefunccallablerE   r   s   &r(   r   r   h  sS    sJ||#w **}}Cy!!!
 r9   c                    \        V \        4      '       d   V P                  ! V3/ VB # \        V 4      '       d
   V ! V3/ VB # V # )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<   r   _eval_expressionr   )maybe_callabler/   kwargss   &&,r(   apply_if_callabler   y  sH     .*--..s=f==	.	!	!c,V,,r9   c                <   \         P                  ! V 4      '       g<   \        V \        4      '       d   \	        \        V P
                  4      # \        V 4      p \        V \        P                  4      '       g   \        RV  24      hV \        8X  d   \        R4      hV # )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_factoryrE   r   r   Mappingr   )intos   &r(   standardize_mappingr     sy    * ??4  dK((;(<(<==DzdCKK((,TF344{IJJKr9   c                    V ^8  d   QhRRRR/# )r2   stateznp.random.Generatorr4   r6   )r7   s   "r(   r8   r8     s     H H+ H0C Hr9   c                    R # rQ   r6   r   s   &r(   random_stater     s    EHr9   c                    V ^8  d   QhRRRR/# )r2   r   zHint | np.ndarray | np.random.BitGenerator | np.random.RandomState | Noner4   znp.random.RandomStater6   )r7   s   "r(   r8   r8     s        S  r9   c                    R # rQ   r6   r   s   &r(   r   r     s      r9   c                   V ^8  d   QhRR/# )r2   r   zRandomState | Noner6   )r7   s   "r(   r8   r8     s      
  
*  
r9   c                   \        V 4      '       g;   \        V \        P                  \        P                  P
                  34      '       d    \        P                  P                  V 4      # \        V \        P                  P                  4      '       d   V # \        V \        P                  P                  4      '       d   V # V f   \        P                  # \        R4      h)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<   r=   r>   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+
 	
r9   _Tc          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r2   r/   r   r   zCallable[Concatenate[_T, P], T]rX   zP.argsr   zP.kwargsr4   r"   r6   )r7   s   "r(   r8   r8     s:      	
)  	
 r9   c                    R # rQ   r6   r/   r   rX   r   s   &&*,r(   piper          	r9   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	r2   r/   r   r   ztuple[Callable[..., T], str]rX   r   r4   r"   r6   )r7   s   "r(   r8   r8     s:      	
&  	
 r9   c                    R # rQ   r6   r   s   &&*,r(   r   r     r   r9   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r2   r/   r   r   z>Callable[Concatenate[_T, P], T] | tuple[Callable[..., T], str]rX   r   r   r4   r"   r6   )r7   s   "r(   r8   r8     s:     &* &*	&*
H&* &* 	&*
 &*r9   c                    \        V\        4      '       d'   Vw  rEWS9   d   V R2p\        V4      hWV&   V! V/ VB # V! V .VO5/ VB # )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<   r   r-   )r/   r   rX   r   func_targetmsgs   &&*,   r(   r   r     sa    : $HKLCS/!vd%f%%C)$)&))r9   c                d   a  V 3R lp\        S \        P                  \        34      '       d   V# S # )zj
Returns a function that will map names/labels, dependent if mapper
is a dict, Series or just a function.
c                (   < V S9   d
   SV ,          # V # rQ   r6   )r~   mappers   &r(   fget_rename_function.<locals>.f  s    ;!9Hr9   )r<   r   r   r   )r   r   s   f r(   get_rename_functionr     s*     6CKK#;<<1H&Hr9   c                    V ^8  d   QhRRRR/# )r2   r   z"Hashable | Iterable | AnyArrayLiker4   zlist | AnyArrayLiker6   )r7   s   "r(   r8   r8   &  s      .r9   c                    \        V \        \        P                  \        \
        \        34      '       d   V # \        V \        P                  4      '       d"   \        V \        4      '       g   \        V 4      # V .# )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<   rC   r=   r>   r   r   r   r   r	   r   )r   s   &r(   convert_to_list_liker   &  sT     &4XyBSTUU	FCLL	)	)*VS2I2IF|8Or9   c               $    V ^8  d   QhRRRRRR/# )r2   attrr   	conditionr5   r4   zGenerator[None]r6   )r7   s   "r(   r8   r8   6  s!     * *C *4 *? *r9   c              #     "   V'       d   \        W4      p\        WV4        V x  V'       d   \        WX4       R# R#   T'       d   \        YX4       i i ; i5i)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)getattrsetattr)r/   r   valuer   	old_values   &&&& r(   temp_setattrr   5  sL     * C&	5!*	Cy) 9Cy) s    A? AAAc                    V ^8  d   QhRRRR/# )r2   indexr#   r4   Noner6   )r7   s   "r(   r8   r8   T  s     

 

e 

 

r9   c                    \        V 4      \        V4      8w  d%   \        R\        V 4       R\        V4       R24      hR# )z;
Check the length of data matches the length of the index.
zLength of values (z") does not match length of index ()N)rD   r-   )datar   s   &&r(   require_length_matchr   T  sI     4yCJD	{ E
|1
 	
 r9   r   maxminrk   rc   meanprodstdvarmediancumprodcumsumc                    V ^8  d   QhRRRR/# )r2   rT   r   r4   z
str | Noner6   )r7   s   "r(   r8   r8   ~  s     " " "j "r9   c                ,    \         P                  V 4      # )z@
if we define an internal function for this argument, return it
)_cython_tableget)rT   s   &r(   get_cython_funcr  ~  s     S!!r9   c                    V ^8  d   QhRRRR/# )r2   nameszSequence[Hashable | None]r4   zlist[Hashable]r6   )r7   s   "r(   r8   r8     s     T T7 TN Tr9   c                ^    \        V 4       UUu. uF  w  rVf   RV 2MTNK  	  upp# u uppi )z
If a name is missing then replace it by level_n, where n is the count

Parameters
----------
names : list-like
    list of column names or None values.

Returns
-------
list
    list of column names with the None values replaced.
level_)	enumerate)r  ir,   s   &  r(   fill_missing_namesr    s6     CLEBRSBRwqDLfQCLd2BRSSSs   )c                    \         P                  ! ^4      pVP                  P                  4        F  pW J g   K
   R# 	  R# )aQ  
Helper function used in detecting chained assignment.

If the pandas object (DataFrame/Series) is a local variable
in the caller's frame, it should not be a case of chained
assignment or method call.

For example:

def test():
    df = pd.DataFrame(...)
    df["a"] = 1  # not chained assignment

Inside ``df.__setitem__``, we call this function to check whether `df`
(`self`) is a local variable in `test` frame (the frame calling setitem). If
so, we know it is not a case of chained assignment (even when the refcount
of `df` is below the threshold due to optimization of local variables).
TF)sys	_getframef_localsr   )r/   framevs   &  r(   is_local_in_caller_framer    s6    & MM!E^^""$8 % r9   ).rQ   )T)m__doc__
__future__r   builtinscollectionsr   r   collections.abcr   r   r   r   r	   r
   
contextlib	functoolsr   r   r  typingr   r   r   r   r   r   numpyr=   pandas._libsr   pandas.core.dtypes.castr   pandas.core.dtypes.commonr   r   pandas.core.dtypes.genericr   r   r   r   r   pandas.core.dtypes.inferencer   pandas.core.colr   pandas._typingr   r   r   r    r!   r"   pandasr#   r%   r0   rI   rN   rY   rd   rl   rs   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   contextmanagerr   r   r   r   r   rk   rc   nansumr   nanmeanr   nanprodr   nanstdr   nanvarr   	nanmediannanmaxnanminr   
nancumprodr  	nancumsumr  r  r  r  r6   r9   r(   <module>r1     s   #      
    K  = &  0
5p,4,,00, 
 
 
 V 
 V>:		<	"&@ 
 H 
 H 
  
 
 
F T] 
 
 
 
&*RI * *<

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"r9   