
    Mh<'                        S r SSKJr  SSKJrJr  SSKrSSKJr  SSK	J
r
   " S S5      r " S	 S
5      rSS S4         SS jjr " S S5      r\" SSS9SS j5       r\" \SS9SS j5       r\" \SS9SS j5       r\" \SS9SS j5       rg)z

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

    )annotations)CallablefinalN)doc)find_stack_levelc                  |   ^  \ rS rSr% \" 5       rS\S'   \" 5       rS\S'   \	S
S j5       r
S
S jrSU 4S jjrS	rU =r$ )DirNamesMixin   set[str]
_accessorszfrozenset[str]_hidden_attrsc                4    U R                   U R                  -  $ )z*
Delete unwanted __dir__ for this object.
)r   r   )selfs    F/var/www/html/env/lib/python3.13/site-packages/pandas/core/accessor.py_dir_deletionsDirNamesMixin._dir_deletions   s    
 !3!333    c                j    U R                    Vs1 s H  n[        X5      (       d  M  UiM     sn$ s  snf )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                   > [        [        TU ]	  5       5      nXR                  5       -
  U R	                  5       -  n[        U5      $ )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__$   s?     "#&&((D,?,?,AAbzr    )returnr   )r"   	list[str])__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                  l    \ rS rSrSrSS jrSS jrSS jr\SS S4           SS	 jj5       r	S
r
g)PandasDelegate1   z8
Abstract base class for delegating methods/properties.
c                    [        SU 35      e)NzYou cannot access the property 	TypeErrorr   nameargskwargss       r   _delegate_property_get%PandasDelegate._delegate_property_get6   s    9$@AAr   c                     [        SU S35      e)NzThe property z cannot be setr0   )r   r3   valuer4   r5   s        r   _delegate_property_set%PandasDelegate._delegate_property_set9   s    -v^<==r   c                    [        SU 35      e)NzYou cannot call method r0   r2   s       r   _delegate_methodPandasDelegate._delegate_method<   s    1$899r   Fc                    U $ Nr!   xs    r   <lambda>PandasDelegate.<lambda>F   s    1r   Tc                   ^^ SUU4S jjnSUU4S jjnU H\  n	U(       d  [        TT" U	5      S5      c  M   US:X  a	  U" U	5      n
OU" U	5      n
U(       d  [        X	5      (       a  MP  [        X	U
5        M^     g)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 doc-strings.
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           
        >^  U 4S jnU 4S jnT Ul         T Ul         [        UU[        TT" T 5      5      R                  S9$ )Nc                &   > U R                  T5      $ r@   )r6   )r   r3   s    r   _getter[PandasDelegate._add_delegate_accessors.<locals>._create_delegator_property.<locals>._getter_   s    22488r   c                (   > U R                  TU5      $ r@   )r:   )r   
new_valuesr3   s     r   _setter[PandasDelegate._add_delegate_accessors.<locals>._create_delegator_property.<locals>._setterb   s    224DDr   )fgetfsetr   )r$   propertygetattr__doc__)r3   rH   rL   accessor_mappingdelegates   `  r   _create_delegator_propertyJPandasDelegate._add_delegate_accessors.<locals>._create_delegator_property^   sI    9E  $G#GH&6t&<=EE r   c                f   >^  U 4S jnT Ul         [        TT" T 5      5      R                  Ul        U$ )Nc                0   > U R                   " T/UQ70 UD6$ r@   )r=   )r   r4   r5   r3   s      r   fSPandasDelegate._add_delegate_accessors.<locals>._create_delegator_method.<locals>.fo   s    ,,TCDCFCCr   )r$   rQ   rR   )r3   rY   rS   rT   s   ` r   _create_delegator_methodHPandasDelegate._add_delegate_accessors.<locals>._create_delegator_methodn   s1    D AJ*:4*@AIIAIHr   NrP   r3   str)rQ   r   setattr)clsrT   	accessorstyp	overwriterS   raise_on_missingrU   r[   r3   rY   s    `   `     r   _add_delegate_accessors&PandasDelegate._add_delegate_accessors?   ss    >	 	 	 	 D$H&6t&<dCKj .t4,T2  2 21% r   r!   Nr]   )ra   r#   rb   r^   rc   boolrS   Callable[[str], str]rd   rg   r"   None)r$   r%   r&   r'   rR   r6   r:   r=   classmethodre   r*   r!   r   r   r-   r-   1   sz    B>:   1<!%E& E& 	E&
 E& /E& E& 
E& E&r   r-   Fc                    U $ r@   r!   rA   s    r   rC   rC      s    qr   Tc                (   ^ ^^^^^ UUU UUU4S jnU$ )ak  
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 & doc-strings.
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           	     0   > U R                  TTTTTTS9  U $ )N)rc   rS   rd   )re   )r`   rS   ra   rT   rc   rd   rb   s    r   add_delegate_accessors.delegate_names.<locals>.add_delegate_accessors   s/    ##-- 	$ 	
 
r   r!   )rT   ra   rb   rc   rS   rd   rn   s   `````` r   delegate_namesrp      s    P	 	 "!r   c                  (    \ rS rSrSrSS jrS rSrg)CachedAccessor   ai  
Custom property-like object.

A descriptor for caching 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                    Xl         X l        g r@   )_name	_accessor)r   r3   r   s      r   __init__CachedAccessor.__init__   s    
!r   c                    Uc  U R                   $ U R                  U5      n[        R                  XR                  U5        U$ r@   )rv   object__setattr__ru   )r   objr`   accessor_objs       r   __get__CachedAccessor.__get__   s;    ;>>!~~c*
 	3

L9r   )rv   ru   N)r3   r^   r"   ri   )r$   r%   r&   r'   rR   rw   r~   r*   r!   r   r   rr   rr      s    &"
r   rr    )klassothersc                   ^ ^ UU 4S jnU$ )as  
Register a custom accessor on {klass} 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
-----
When accessed, your accessor will be initialized with the pandas object
the user is interacting with. So the signature must be

.. code-block:: python

    def __init__(self, pandas_object):  # noqa: E999
        ...

For consistency with pandas methods, you should raise an ``AttributeError``
if the data passed to your accessor has an incorrect dtype.

>>> pd.Series(['a', 'b']).dt
Traceback (most recent call last):
...
AttributeError: Can only use .dt accessor with datetimelike values

Examples
--------
In your library code::

    import pandas as pd

    @pd.api.extensions.register_dataframe_accessor("geo")
    class GeoAccessor:
        def __init__(self, pandas_obj):
            self._obj = pandas_obj

        @property
        def center(self):
            # return the geographic center point of this DataFrame
            lat = self._obj.latitude
            lon = self._obj.longitude
            return (float(lon.mean()), float(lat.mean()))

        def plot(self):
            # plot this array's data on a map, e.g., using Cartopy
            pass

Back in an interactive IPython session:

    .. code-block:: ipython

        In [1]: ds = pd.DataFrame({{"longitude": np.linspace(0, 10),
           ...:                    "latitude": np.linspace(0, 20)}})
        In [2]: ds.geo.center
        Out[2]: (5.0, 10.0)
        In [3]: ds.geo.plot()  # plots data on a map
c           
       > [        TT5      (       aG  [        R                  " S[        U 5       S[        T5       S[        T5       S3[        [        5       S9  [        TT[        TU 5      5        TR                  R                  T5        U $ )Nzregistration of accessor z under name z
 for type z: is overriding a preexisting attribute with the same name.)
stacklevel)
r   warningswarnreprUserWarningr   r_   rr   r   add)r   r`   r3   s    r   	decorator%_register_accessor.<locals>.decorator2  s~    3MM+DN+;<:,jc 401 +- 	T>$9:4 r   r!   )r3   r`   r   s   `` r   _register_accessorr      s    R r   	DataFrame)r   c                $    SSK Jn  [        X5      $ )Nr   )r   )pandasr   r   )r3   r   s     r   register_dataframe_accessorr   B  s     d..r   Seriesc                $    SSK Jn  [        X5      $ )Nr   )r   )r   r   r   )r3   r   s     r   register_series_accessorr   I  s    d++r   Indexc                $    SSK Jn  [        X5      $ )Nr   )r   )r   r   r   )r3   r   s     r   register_index_accessorr   P  s    d**r   )
ra   r#   rb   r^   rc   rg   rS   rh   rd   rg   r]   )rR   
__future__r   typingr   r   r   pandas.util._decoratorsr   pandas.util._exceptionsr   r	   r-   rp   rr   r   r   r   r   r!   r   r   <module>r      s    #  ' 4 <T& T&v -8!3"3" 
3" 	3"
 +3" 3"x" "J 2bU Up {+/ ,/ x(, ), w'+ (+r   