+
    ŜiC                    d   R t ^ RIHt ^ RIt^ RIHtHt ^ RIt^ RIH	t	 ^ RI
Ht ]'       d   ^ RIHt ^ RIHt ^ RIHt ^ R	IHt  ! R
 R4      t ! R R4      tRR R3R R llt ! R R4      t]tR R ltRt]	! R4      R R l4       tRt]	! R4      R R l4       tRt]	! R4      R R  l4       tR# )!z

accessor.py contains base classes for implementing accessor properties
that can be mixed into or pinned onto other pandas classes.

)annotationsN)TYPE_CHECKINGfinal)
set_module)find_stack_level)Callable)TypeTIndex)NDFramec                     a  ] tR t^t$ ]! 4       tR]R&   ]! 4       tR]R&   ]	R R l4       t
R R ltR	 V 3R
 lltRtV ;t# )DirNamesMixinset[str]
_accessorszfrozenset[str]_hidden_attrsc                   V ^8  d   QhRR/#    returnr    )formats   "]/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/pandas/core/accessor.py__annotate__DirNamesMixin.__annotate__$   s     4 4 4    c                <    V P                   V P                  ,          # )z*
Delete unwanted __dir__ for this object.
)r   r   )selfs   &r   _dir_deletionsDirNamesMixin._dir_deletions#   s    
 !3!333r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   *   s     U U Ur   c                j    V P                    Uu0 uF  p\        W4      '       g   K  VkK  	  up# u upi )z)
Add additional __dir__ for this object.
)r   hasattr)r   accessors   & r   _dir_additionsDirNamesMixin._dir_additions*   s)     *.TXGD<STTTs   00c                   V ^8  d   QhRR/# )r   r   	list[str]r   )r   s   "r   r   r   0   s     
 
 
r   c                   < \        \        SV `	  4       4      pWP                  4       ,
          V P	                  4       ,          p\        V4      # )zX
Provide method name lookup and completion.

Notes
-----
Only provide 'public' methods.
)setsuper__dir__r   r#   sorted)r   rv	__class__s   & r   r*   DirNamesMixin.__dir__0   s?     "#&&((D,?,?,AAbzr   r   )__name__
__module____qualname____firstlineno__r(   r   __annotations__	frozensetr   r   r   r#   r*   __static_attributes____classcell__)r-   s   @r   r   r      s=    5J $-KM>/
4 4U
 
r   r   c                  `    ] tR t^=tRtR R ltR R ltR R lt]RR	 R
3R R ll4       t	Rt
R# )PandasDelegatez8
Abstract base class for delegating methods/properties.
c                   V ^8  d   QhRR/# r   namestrr   )r   s   "r   r   PandasDelegate.__annotate__B   s     B B3 Br   c                	    \        R V 24      h)zYou cannot access the property 	TypeErrorr   r;   argskwargss   &&*,r   _delegate_property_get%PandasDelegate._delegate_property_getB   s    9$@AAr   c                    V ^8  d   QhRRRR/# r   r;   r<   r   Noner   )r   s   "r   r   r=   E   s     > >3 >4 >r   c                	     \        R V R24      h)zThe property z cannot be setr?   )r   r;   valuerB   rC   s   &&&*,r   _delegate_property_set%PandasDelegate._delegate_property_setE   s    -v^<==r   c                   V ^8  d   QhRR/# r:   r   )r   s   "r   r   r=   H   s     : :S :r   c                	    \        R V 24      h)zYou cannot call method r?   rA   s   &&*,r   _delegate_methodPandasDelegate._delegate_methodH   s    1$899r   Fc                	    V # Nr   xs   &r   <lambda>PandasDelegate.<lambda>R   s    1r   Tc               0    V ^8  d   QhRRRRRRRRR	RR
R/# )r   	accessorsr&   typr<   	overwriteboolaccessor_mappingCallable[[str], str]raise_on_missingr   rH   r   )r   s   "r   r   r=   L   sP     E& E& E& 	E&
 E& /E& E& 
E&r   c                   aa R VV3R llpR VV3R llpV Fa  p	V'       g   \        SS! V	4      R4      f   K"  VR8X  d
   V! V	4      p
MV! V	4      p
V'       g   \        W	4      '       d   KU  \        W	V
4       Kc  	  R# )a\  
Add accessors to cls from the delegate class.

Parameters
----------
cls
    Class to add the methods/properties to.
delegate
    Class to get methods/properties and docstrings.
accessors : list of str
    List of accessors to add.
typ : {'property', 'method'}
overwrite : bool, default False
    Overwrite the method/property in the target class if it exists.
accessor_mapping: Callable, default lambda x: x
    Callable to map the delegate's function to the cls' function.
raise_on_missing: bool, default True
    Raise if an accessor does not exist on delegate.
    False skips the missing accessor.
c                   V ^8  d   QhRR/# r:   r   )r   s   "r   r   <PandasDelegate._add_delegate_accessors.<locals>.__annotate__j   s     	 	S 	r   c           
        <a  V 3R  lpV 3R lpS Vn         S Vn         \        VV\        SS! S 4      4      P                  R7      # )c                &   < V P                  S4      # rR   )rD   )r   r;   s   &r   _getter[PandasDelegate._add_delegate_accessors.<locals>._create_delegator_property.<locals>._getterk   s    22488r   c                (   < V P                  SV4      # rR   )rK   )r   
new_valuesr;   s   &&r   _setter[PandasDelegate._add_delegate_accessors.<locals>._create_delegator_property.<locals>._settern   s    224DDr   )fgetfsetdoc)r/   propertygetattr__doc__)r;   rd   rh   r\   delegates   f  r   _create_delegator_propertyJPandasDelegate._add_delegate_accessors.<locals>._create_delegator_propertyj   sI    9E  $G#GH&6t&<=EE r   c                   V ^8  d   QhRR/# r:   r   )r   s   "r   r   ra   z   s     	 	3 	r   c                l   <a  \        SS! S 4      4      p\        P                  ! V4      V 3R  l4       pV# )c                0   < V P                   ! S.VO5/ VB # rR   )rO   )r   rB   rC   r;   s   &*,r   fSPandasDelegate._add_delegate_accessors.<locals>._create_delegator_method.<locals>.f}   s    ,,TCDCFCCr   )rn   	functoolswraps)r;   methodrv   r\   rp   s   f  r   _create_delegator_methodHPandasDelegate._add_delegate_accessors.<locals>._create_delegator_methodz   s9    X'7'=>F__V$D %D Hr   Nrm   )rn   r!   setattr)clsrp   rX   rY   rZ   r\   r^   rq   r{   r;   rv   s   &f&&&f&    r   _add_delegate_accessors&PandasDelegate._add_delegate_accessorsK   ss    >	 	 	 	 D$H&6t&<dCKj .t4,T2  2 21% r   r   N)r/   r0   r1   r2   ro   rD   rK   rO   classmethodr   r5   r   r   r   r8   r8   =   s8    B>:   1<!%E& E&r   r8   Fc                    V # rR   r   rS   s   &r   rU   rU      s    qr   Tc          
     ,    V ^8  d   QhRRRRRRRRR	R/# )
r   rX   r&   rY   r<   rZ   r[   r\   r]   r^   r   )r   s   "r   r   r      s<     3" 3"3" 
3" 	3"
 +3" 3"r   c                (   a aaaaa VVV VVV3R lpV# )aj  
Add delegated names to a class using a class decorator.  This provides
an alternative usage to directly calling `_add_delegate_accessors`
below a class definition.

Parameters
----------
delegate : object
    The class to get methods/properties & docstrings.
accessors : Sequence[str]
    List of accessor to add.
typ : {'property', 'method'}
overwrite : bool, default False
   Overwrite the method/property in the target class if it exists.
accessor_mapping: Callable, default lambda x: x
    Callable to map the delegate's function to the cls' function.
raise_on_missing: bool, default True
    Raise if an accessor does not exist on delegate.
    False skips the missing accessor.

Returns
-------
callable
    A class decorator.

Examples
--------
@delegate_names(Categorical, ["categories", "ordered"], "property")
class CategoricalAccessor(PandasDelegate):
    [...]
c           	     6   < V P                  SSSSSSR 7       V # ))rZ   r\   r^   )r   )r~   r\   rX   rp   rZ   r^   rY   s   &r   add_delegate_accessors.delegate_names.<locals>.add_delegate_accessors   s/    ##-- 	$ 	
 
r   r   )rp   rX   rY   rZ   r\   r^   r   s   ffffff r   delegate_namesr      s    P	 	 "!r   c                  ,    ] tR t^tRtR R ltR tRtR# )Accessoraa  
Custom property-like object.

A descriptor for accessors.

Parameters
----------
name : str
    Namespace that will be accessed under, e.g. ``df.foo``.
accessor : cls
    Class with the extension methods.

Notes
-----
For accessor, The class's __init__ method assumes that one of
``Series``, ``DataFrame`` or ``Index`` as the
single argument ``data``.
c                    V ^8  d   QhRRRR/# rG   r   )r   s   "r   r   Accessor.__annotate__   s     " "S "t "r   c                	    Wn         W n        R # rR   )_name	_accessor)r   r;   r"   s   &&&r   __init__Accessor.__init__   s    
!r   c                	D    Vf   V P                   # V P                  V4      # rR   )r   )r   objr~   s   &&&r   __get__Accessor.__get__   s     ;>>!~~c""r   )r   r   N)r/   r0   r1   r2   ro   r   r   r5   r   r   r   r   r      s    &"#r   r   c               $    V ^8  d   QhRRRRRR/# )r   r;   r<   r~   ztype[NDFrame | Index]r   Callable[[TypeT], TypeT]r   )r   s   "r   r   r      s$     : :
:)::r   c                   a a R VV 3R llpV# )a%  
Register a custom accessor on objects.

Parameters
----------
name : str
    Name under which the accessor should be registered. A warning is issued
    if this name conflicts with a preexisting attribute.

Returns
-------
callable
    A class decorator.

See Also
--------
register_dataframe_accessor : Register a custom accessor on DataFrame objects.
register_series_accessor : Register a custom accessor on Series objects.
register_index_accessor : Register a custom accessor on Index objects.

Notes
-----
This function allows you to register a custom-defined accessor class
for pandas objects (DataFrame, Series, or Index).
The requirements for the accessor class are as follows:

* Must contain an init method that:

  * accepts a single object

  * raises an AttributeError if the object does not have correctly
    matching inputs for the accessor

* Must contain a method for each access pattern.

  * The methods should be able to take any argument signature.

  * Accessible using the @property decorator if no additional arguments are
    needed.

c                    V ^8  d   QhRRRR/# )r   r"   r   r   r   )r   s   "r   r   (_register_accessor.<locals>.__annotate__  s      E e r   c           	        < \        SS4      '       d3   \        P                  ! R V : RS: RS: R2\        \	        4       R7       \        SS\        SV 4      4       SP                  P                  S4       V # )zregistration of accessor z under name z
 for type z: is overriding a preexisting attribute with the same name.)
stacklevel)	r!   warningswarnUserWarningr   r}   r   r   add)r"   r~   r;   s   &r   	decorator%_register_accessor.<locals>.decorator  sq    3MM+H<|(*SG ,01 +- 	T8D(344 r   r   )r;   r~   r   s   ff r   _register_accessorr      s    Z  r   a  
An accessor that only accepts integers could
have a class defined like this:

>>> @pd.api.extensions.register_dataframe_accessor("int_accessor")
... class IntAccessor:
...     def __init__(self, pandas_obj):
...         if not all(pandas_obj[col].dtype == 'int64' for col in pandas_obj.columns):
...             raise AttributeError("All columns must contain integer values only")
...         self._obj = pandas_obj
...
...     def sum(self):
...         return self._obj.sum()
...
>>> df = pd.DataFrame([[1, 2], ['x', 'y']])
>>> df.int_accessor
Traceback (most recent call last):
...
AttributeError: All columns must contain integer values only.
>>> df = pd.DataFrame([[1, 2], [3, 4]])
>>> df.int_accessor.sum()
0    4
1    6
dtype: int64zpandas.api.extensionsc                    V ^8  d   QhRRRR/# r   r;   r<   r   r   r   )r   s   "r   r   r   F  s     E/ E/c E/.F E/r   c                $    ^ RI Hp \        W4      # )a0  
Register a custom accessor on DataFrame objects.

Parameters
----------
name : str
    Name under which the accessor should be registered. A warning is issued
    if this name conflicts with a preexisting attribute.

Returns
-------
callable
    A class decorator.

See Also
--------
register_dataframe_accessor : Register a custom accessor on DataFrame objects.
register_series_accessor : Register a custom accessor on Series objects.
register_index_accessor : Register a custom accessor on Index objects.

Notes
-----
This function allows you to register a custom-defined accessor class for DataFrame.
The requirements for the accessor class are as follows:

* Must contain an init method that:

  * accepts a single DataFrame object

  * raises an AttributeError if the DataFrame object does not have correctly
    matching inputs for the accessor

* Must contain a method for each access pattern.

  * The methods should be able to take any argument signature.

  * Accessible using the @property decorator if no additional arguments are
    needed.

Examples
--------
An accessor that only accepts integers could
have a class defined like this:

>>> @pd.api.extensions.register_dataframe_accessor("int_accessor")
... class IntAccessor:
...     def __init__(self, pandas_obj):
...         if not all(
...             pandas_obj[col].dtype == "int64" for col in pandas_obj.columns
...         ):
...             raise AttributeError("All columns must contain integer values only")
...         self._obj = pandas_obj
...
...     def sum(self):
...         return self._obj.sum()
>>> df = pd.DataFrame([[1, 2], ["x", "y"]])
>>> df.int_accessor
Traceback (most recent call last):
...
AttributeError: All columns must contain integer values only.
>>> df = pd.DataFrame([[1, 2], [3, 4]])
>>> df.int_accessor.sum()
0    4
1    6
dtype: int64
)	DataFrame)pandasr   r   )r;   r   s   & r   register_dataframe_accessorr   E  s    H !d..r   a  
An accessor that only accepts integers could
have a class defined like this:

>>> @pd.api.extensions.register_series_accessor("int_accessor")
... class IntAccessor:
...     def __init__(self, pandas_obj):
...         if not pandas_obj.dtype == 'int64':
...             raise AttributeError("The series must contain integer data only")
...         self._obj = pandas_obj
...
...     def sum(self):
...         return self._obj.sum()
...
>>> df = pd.Series([1, 2, 'x'])
>>> df.int_accessor
Traceback (most recent call last):
...
AttributeError: The series must contain integer data only.
>>> df = pd.Series([1, 2, 3])
>>> df.int_accessor.sum()
6c                    V ^8  d   QhRRRR/# r   r   )r   s   "r   r   r     s     A, A,3 A,+C A,r   c                $    ^ RI Hp \        W4      # )a  
Register a custom accessor on Series objects.

Parameters
----------
name : str
    Name under which the accessor should be registered. A warning is issued
    if this name conflicts with a preexisting attribute.

Returns
-------
callable
    A class decorator.

See Also
--------
register_dataframe_accessor : Register a custom accessor on DataFrame objects.
register_series_accessor : Register a custom accessor on Series objects.
register_index_accessor : Register a custom accessor on Index objects.

Notes
-----
This function allows you to register a custom-defined accessor class for Series.
The requirements for the accessor class are as follows:

* Must contain an init method that:

  * accepts a single Series object

  * raises an AttributeError if the Series object does not have correctly
    matching inputs for the accessor

* Must contain a method for each access pattern.

  * The methods should be able to take any argument signature.

  * Accessible using the @property decorator if no additional arguments are
    needed.

Examples
--------
An accessor that only accepts integers could
have a class defined like this:

>>> @pd.api.extensions.register_series_accessor("int_accessor")
... class IntAccessor:
...     def __init__(self, pandas_obj):
...         if not pandas_obj.dtype == "int64":
...             raise AttributeError("The series must contain integer data only")
...         self._obj = pandas_obj
...
...     def sum(self):
...         return self._obj.sum()
>>> df = pd.Series([1, 2, "x"])
>>> df.int_accessor
Traceback (most recent call last):
...
AttributeError: The series must contain integer data only.
>>> df = pd.Series([1, 2, 3])
>>> df.int_accessor.sum()
6
)Series)r   r   r   )r;   r   s   & r   register_series_accessorr     s    @ d++r   a[  
An accessor that only accepts integers could
have a class defined like this:

>>> @pd.api.extensions.register_index_accessor("int_accessor")
... class IntAccessor:
...     def __init__(self, pandas_obj):
...         if not all(isinstance(x, int) for x in pandas_obj):
...             raise AttributeError("The index must only be an integer value")
...         self._obj = pandas_obj
...
...     def even(self):
...         return [x for x in self._obj if x % 2 == 0]
>>> df = pd.DataFrame.from_dict(
...     {"row1": {"1": 1, "2": "a"}, "row2": {"1": 2, "2": "b"}}, orient="index"
... )
>>> df.index.int_accessor
Traceback (most recent call last):
...
AttributeError: The index must only be an integer value.
>>> df = pd.DataFrame(
...     {"col1": [1, 2, 3, 4], "col2": ["a", "b", "c", "d"]}, index=[1, 2, 5, 8]
... )
>>> df.index.int_accessor.even()
[2, 8]c                    V ^8  d   QhRRRR/# r   r   )r   s   "r   r   r     s     E+ E+# E+*B E+r   c                $    ^ RI Hp \        W4      # )a}  
Register a custom accessor on Index objects.

Parameters
----------
name : str
    Name under which the accessor should be registered. A warning is issued
    if this name conflicts with a preexisting attribute.

Returns
-------
callable
    A class decorator.

See Also
--------
register_dataframe_accessor : Register a custom accessor on DataFrame objects.
register_series_accessor : Register a custom accessor on Series objects.
register_index_accessor : Register a custom accessor on Index objects.

Notes
-----
This function allows you to register a custom-defined accessor class for Index.
The requirements for the accessor class are as follows:

* Must contain an init method that:

  * accepts a single Index object

  * raises an AttributeError if the Index object does not have correctly
    matching inputs for the accessor

* Must contain a method for each access pattern.

  * The methods should be able to take any argument signature.

  * Accessible using the @property decorator if no additional arguments are
    needed.

Examples
--------
An accessor that only accepts integers could
have a class defined like this:

>>> @pd.api.extensions.register_index_accessor("int_accessor")
... class IntAccessor:
...     def __init__(self, pandas_obj):
...         if not all(isinstance(x, int) for x in pandas_obj):
...             raise AttributeError("The index must only be an integer value")
...         self._obj = pandas_obj
...
...     def even(self):
...         return [x for x in self._obj if x % 2 == 0]
>>> df = pd.DataFrame.from_dict(
...     {"row1": {"1": 1, "2": "a"}, "row2": {"1": 2, "2": "b"}}, orient="index"
... )
>>> df.index.int_accessor
Traceback (most recent call last):
...
AttributeError: The index must only be an integer value.
>>> df = pd.DataFrame(
...     {"col1": [1, 2, 3, 4], "col2": ["a", "b", "c", "d"]}, index=[1, 2, 5, 8]
... )
>>> df.index.int_accessor.even()
[2, 8]
r	   )r   r
   r   )r;   r
   s   & r   register_index_accessorr     s    H d**r   ) ro   
__future__r   rx   typingr   r   r   pandas.util._decoratorsr   pandas.util._exceptionsr   collections.abcr   pandas._typingr   r   r
   pandas.core.genericr   r   r8   r   r   CachedAccessorr   _register_df_examplesr   _register_series_examplesr   _register_index_examplesr   r   r   r   <module>r      s    #   5($+ <T& T&v -8!3"l# #B :z 4 #$E/ %E/P 0 #$A, %A,H
 6 #$E+ %E+r   