Ë
    ¤eh<'  ã                  ó,  — d Z ddlmZ ddlmZmZ ddlZddlmZ ddl	m
Z
  G d„ d«      Z G d	„ d
«      Zdd„ df	 	 	 	 	 	 	 	 	 dd„Z G d„ d«      Z edd¬«      dd„«       Z eed¬«      dd„«       Z eed¬«      dd„«       Z eed¬«      dd„«       Zy)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                  ól   ‡ — e Zd ZU  e«       Zded<    e«       Zded<   edd„«       Z	dd„Z
d	ˆ fd„Zˆ xZS )
ÚDirNamesMixinúset[str]Ú
_accessorszfrozenset[str]Ú_hidden_attrsc                ó4   — | j                   | j                  z  S )z:
        Delete unwanted __dir__ for this object.
        )r   r   )Úselfs    úR/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/pandas/core/accessor.pyÚ_dir_deletionszDirNamesMixin._dir_deletions   s   € ð
 �‰ ×!3Ñ!3Ñ3Ð3ó    c                óZ   — | j                   D �ch c]  }t        | |«      sŒ|’Œ c}S c c}w )z9
        Add additional __dir__ for this object.
        )r   Úhasattr)r   Úaccessors     r   Ú_dir_additionszDirNamesMixin._dir_additions   s%   € ð *.¯©ÖT˜X¼GÀDÈ(Õ<S’ÒTÐTùÒTs   �(¡(c                ó�   •— t        t        ‰| �	  «       «      }|| j                  «       z
  | j	                  «       z  }t        |«      S )z€
        Provide method name lookup and completion.

        Notes
        -----
        Only provide 'public' methods.
        )ÚsetÚsuperÚ__dir__r   r   Úsorted)r   ÚrvÚ	__class__s     €r   r   zDirNamesMixin.__dir__$   sA   ø€ ô ”‘‘Ó"Ó#ˆØ�4×&Ñ&Ó(Ñ(¨D×,?Ñ,?Ó,AÑAˆÜ�b‹zÐr   )Úreturnr
   )r   ú	list[str])Ú__name__Ú
__module__Ú__qualname__r   r   Ú__annotations__Ú	frozensetr   r   r   r   r   Ú__classcell__)r   s   @r   r	   r	      s=   ø… Ù›5€J�Ó Ù$-£K€M�>Ó/à
ò4ó ð4óU÷
ñ 
r   r	   c                  óZ   — e Zd ZdZd
d„Zd
d„Zd
d„Zedd„ df	 	 	 	 	 	 	 	 	 	 	 dd„«       Zy	)ÚPandasDelegatez@
    Abstract base class for delegating methods/properties.
    c                ó   — t        d|› �«      ‚)NzYou cannot access the property ©Ú	TypeError©r   ÚnameÚargsÚkwargss       r   Ú_delegate_property_getz%PandasDelegate._delegate_property_get6   s   € ÜÐ9¸$¸Ð@ÓAÐAr   c                ó    — t        d|› d�«      ‚)NzThe property z cannot be setr(   )r   r+   Úvaluer,   r-   s        r   Ú_delegate_property_setz%PandasDelegate._delegate_property_set9   s   € Ü˜-¨ v¨^Ð<Ó=Ð=r   c                ó   — t        d|› �«      ‚)NzYou cannot call method r(   r*   s       r   Ú_delegate_methodzPandasDelegate._delegate_method<   s   € ÜÐ1°$°Ð8Ó9Ð9r   Fc                ó   — | S ©N© ©Úxs    r   ú<lambda>zPandasDelegate.<lambda>F   s   € ¸1€ r   Tc                óÂ   ‡‡— dˆˆfd„}dˆˆfd„}|D ]J  }	|st        ‰ ‰|	«      d«      €Œ|dk(  r	 ||	«      }
n ||	«      }
|st        | |	«      rŒ>t        | |	|
«       ŒL y)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           
     ó†   •‡ — ˆ fd„}ˆ fd„}‰ |_         ‰ |_         t        ||t        ‰ ‰‰ «      «      j                  ¬«      S )Nc                ó&   •— | j                  ‰«      S r5   )r.   )r   r+   s    €r   Ú_getterz[PandasDelegate._add_delegate_accessors.<locals>._create_delegator_property.<locals>._getter_   s   ø€ Ø×2Ñ2°4Ó8Ð8r   c                ó(   •— | j                  ‰|«      S r5   )r1   )r   Ú
new_valuesr+   s     €r   Ú_setterz[PandasDelegate._add_delegate_accessors.<locals>._create_delegator_property.<locals>._setterb   s   ø€ Ø×2Ñ2°4¸ÓDÐDr   )ÚfgetÚfsetr   )r   ÚpropertyÚgetattrÚ__doc__)r+   r=   r@   Úaccessor_mappingÚdelegates   `  €€r   Ú_create_delegator_propertyzJPandasDelegate._add_delegate_accessors.<locals>._create_delegator_property^   sI   ù€ ô9ôEð  $ˆGÔØ#ˆGÔäØØÜ˜HÑ&6°tÓ&<Ó=×EÑEôð r   c                ód   •‡ — ˆ fd„}‰ |_         t        ‰ ‰‰ «      «      j                  |_        |S )Nc                ó0   •—  | j                   ‰g|¢­i |¤ŽS r5   )r3   )r   r,   r-   r+   s      €r   ÚfzSPandasDelegate._add_delegate_accessors.<locals>._create_delegator_method.<locals>.fo   s    ø€ Ø,�t×,Ñ,¨TÐC°DÒC¸FÑCÐCr   )r   rD   rE   )r+   rK   rF   rG   s   ` €€r   Ú_create_delegator_methodzHPandasDelegate._add_delegate_accessors.<locals>._create_delegator_methodn   s1   ù€ ôDð ˆAŒJÜ Ñ*:¸4Ó*@ÓA×IÑIˆAŒIàˆHr   NrC   ©r+   Ústr)rD   r   Úsetattr)ÚclsrG   Ú	accessorsÚtypÚ	overwriterF   Úraise_on_missingrH   rL   r+   rK   s    `   `     r   Ú_add_delegate_accessorsz&PandasDelegate._add_delegate_accessors?   so   ù€ ö>	ö 	ð ò 	&ˆDá$Ü˜HÑ&6°tÓ&<¸dÓCÐKàà�jÒ Ù.¨tÓ4‘á,¨TÓ2�ñ ¤¨¨TÕ 2Ü˜˜T 1Õ%ñ	&r   NrM   )rQ   r   rR   rN   rS   ÚboolrF   úCallable[[str], str]rT   rV   r   ÚNone)	r   r    r!   rE   r.   r1   r3   ÚclassmethodrU   r6   r   r   r&   r&   1   sz   „ ñóBó>ó:ð ð  Ù1<Ø!%ðE&ð ðE&ð ð	E&ð
 ðE&ð /ðE&ð ðE&ð 
òE&ó ñE&r   r&   Fc                ó   — | S r5   r6   r7   s    r   r9   r9   �   s   € °q€ r   Tc                ó&   ‡ ‡‡‡‡‡— ˆˆˆ ˆˆˆfd„}|S )a×  
    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                ó6   •— | j                  ‰‰‰‰‰‰¬«       | S )N)rS   rF   rT   )rU   )rP   rF   rQ   rG   rS   rT   rR   s    €€€€€€r   Úadd_delegate_accessorsz.delegate_names.<locals>.add_delegate_accessors°   s/   ø€ Ø×#Ñ#ØØØØØ-Ø-ð 	$ô 	
ð ˆ
r   r6   )rG   rQ   rR   rS   rF   rT   r]   s   `````` r   Údelegate_namesr^   ˆ   s   ý€ ÷P	ñ 	ð "Ð!r   c                  ó   — e Zd ZdZdd„Zd„ Zy)ÚCachedAccessora¡  
    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                ó    — || _         || _        y r5   )Ú_nameÚ	_accessor)r   r+   r   s      r   Ú__init__zCachedAccessor.__init__Ø   s   € ØˆŒ
Ø!ˆ�r   c                ó†   — |€| j                   S | j                  |«      }t        j                  || j                  |«       |S r5   )rc   ÚobjectÚ__setattr__rb   )r   ÚobjrP   Úaccessor_objs       r   Ú__get__zCachedAccessor.__get__Ü   s=   € Øˆ;à—>‘>Ð!Ø—~‘~ cÓ*ˆô
 	×Ñ˜3 §
¡
¨LÔ9ØÐr   N)r+   rN   r   rX   )r   r    r!   rE   rd   rj   r6   r   r   r`   r`   Ä   s   „ ñó&"ó
r   r`   Ú )ÚklassÚothersc                ó   ‡ ‡— ˆˆ fd„}|S )aG  
    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        ‰‰«      rIt        j                  dt        | «      › dt        ‰«      › dt        ‰«      › d�t        t        «       ¬«       t        ‰‰t        ‰| «      «       ‰j                  j                  ‰«       | S )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   rO   r`   r   Úadd)r   rP   r+   s    €€r   Ú	decoratorz%_register_accessor.<locals>.decorator2  s{   ø€ Ü�3˜ÔÜ�M‰MØ+¬D°«NÐ+;¸<Ü˜“:�,˜j¬¨c«¨ð 40ð1ô Ü+Ó-õô 	��Tœ>¨$°Ó9Ô:Ø�‰×Ñ˜4Ô Øˆr   r6   )r+   rP   rv   s   `` r   Ú_register_accessorrw   é   s   ù€ õRð Ðr   Ú	DataFrame)rl   c                ó&   — ddl m} t        | |«      S )Nr   )rx   )Úpandasrx   rw   )r+   rx   s     r   Úregister_dataframe_accessorr{   B  s   € å ä˜d IÓ.Ð.r   ÚSeriesc                ó&   — ddl m} t        | |«      S )Nr   )r|   )rz   r|   rw   )r+   r|   s     r   Úregister_series_accessorr~   I  s   € åä˜d FÓ+Ð+r   ÚIndexc                ó&   — ddl m} t        | |«      S )Nr   )r   )rz   r   rw   )r+   r   s     r   Úregister_index_accessorr�   P  s   € åä˜d EÓ*Ð*r   )
rQ   r   rR   rN   rS   rV   rF   rW   rT   rV   rM   )rE   Ú
__future__r   Útypingr   r   rq   Úpandas.util._decoratorsr   Úpandas.util._exceptionsr   r	   r&   r^   r`   rw   r{   r~   r�   r6   r   r   ú<module>r†      sô   ðñõ #÷ó å 'Ý 4÷ñ ÷<T&ñ T&ðv Ù-8Ø!ð3"àð3"ð 
ð3"ð ð	3"ð
 +ð3"ð ó3"÷x"ñ "ñJ ˆ2�bÔòUó ðUñp Ð˜{Ô+ò/ó ,ð/ñ Ð˜xÔ(ò,ó )ð,ñ Ð˜wÔ'ò+ó (ñ+r   