Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pandas/core/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pandas/core/__pycache__/accessor.cpython-312.pyc

�

Mٜg<'��,�dZddlmZddlmZmZddlZddlmZddl	m
Z
Gd�d�ZGd	�d
�Zdd�d
f									dd�Z
Gd�d�Zedd��dd��Zeed��dd��Zeed��dd��Zeed��dd��Zy)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��eZdZUe�Zded<e�Zded<edd��Z	dd�Z
d	�fd�Z�xZS)
�
DirNamesMixin�set[str]�
_accessorszfrozenset[str]�
_hidden_attrsc�4�|j|jzS)z:
        Delete unwanted __dir__ for this object.
        )rr)�selfs �?/usr/local/lib/python3.12/site-packages/pandas/core/accessor.py�_dir_deletionszDirNamesMixin._dir_deletionss��
����!3�!3�3�3�c�Z�|jD�chc]}t||�s�|��c}Scc}w)z9
        Add additional __dir__ for this object.
        )r�hasattr)r�accessors  r�_dir_additionszDirNamesMixin._dir_additionss)��*.���T��X�G�D�(�<S���T�T��Ts�(�(c���tt�|�	��}||j�z
|j	�z}t|�S)z�
        Provide method name lookup and completion.

        Notes
        -----
        Only provide 'public' methods.
        )�set�super�__dir__rr�sorted)r�rv�	__class__s  �rrzDirNamesMixin.__dir__$sA�������"�
#���4�&�&�(�(�D�,?�,?�,A�
A���b�z�r)�returnr
)r�	list[str])
�__name__�
__module__�__qualname__rr�__annotations__�	frozensetrrrrr�
__classcell__)rs@rr	r	s=����5�J�� �$-�K�M�>�/�
�4��4�U�
�
rr	c�Z�eZdZdZd
d�Zd
d�Zd
d�Zedd�df											dd��Zy	)�PandasDelegatez@
    Abstract base class for delegating methods/properties.
    c��td|����)NzYou cannot access the property ��	TypeError�r�name�args�kwargss    r�_delegate_property_getz%PandasDelegate._delegate_property_get6s���9�$��@�A�Arc� �td|�d���)Nz
The property z cannot be setr()rr+�valuer,r-s     r�_delegate_property_setz%PandasDelegate._delegate_property_set9s���-��v�^�<�=�=rc��td|����)NzYou cannot call method r(r*s    r�_delegate_methodzPandasDelegate._delegate_method<s���1�$��8�9�9rFc��|S�N���xs r�<lambda>zPandasDelegate.<lambda>Fs��1rTc�����d��fd�}d��fd�}|D]J}	|st��|	�d���|dk(r	||	�}
n||	�}
|s
t||	�r�>t||	|
��Ly)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
�����fd�}�fd�}�|_�|_t||t�����j��S)Nc�&��|j��Sr5)r.)rr+s �r�_getterz[PandasDelegate._add_delegate_accessors.<locals>._create_delegator_property.<locals>._getter_s����2�2�4�8�8rc�(��|j�|�Sr5)r1)r�
new_valuesr+s  �r�_setterz[PandasDelegate._add_delegate_accessors.<locals>._create_delegator_property.<locals>._setterbs����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��
rc�d����fd�}�|_t�����j|_|S)Nc�0��|j�g|��i|��Sr5)r3)rr,r-r+s   �r�fzSPandasDelegate._add_delegate_accessors.<locals>._create_delegator_method.<locals>.fos ���,�t�,�,�T�C�D�C�F�C�Cr)rrDrE)r+rKrFrGs` ��r�_create_delegator_methodzHPandasDelegate._add_delegate_accessors.<locals>._create_delegator_methodns1���
D��A�J���*:�4�*@�A�I�I�A�I��HrNrC�r+�str)rDr�setattr)�clsrG�	accessors�typ�	overwriterF�raise_on_missingrHrLr+rKs `   `     r�_add_delegate_accessorsz&PandasDelegate._add_delegate_accessors?sj���>	� 	��D�$��H�&6�t�&<�d�C�K���j� �.�t�4��,�T�2�����T� 2���T�1�%�rNrM)rQrrRrNrS�boolrF�Callable[[str], str]rTrVr�None)	rr r!rEr.r1r3�classmethodrUr6rrr&r&1sz���B�>�:�� �1<�!%�E&��E&��	E&�
�E&�/�
E&��E&�
�E&��E&rr&Fc��|Sr5r6r7s rr9r9�s��qrTc�&�������������fd�}|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)rSrFrT)rU)rPrFrQrGrSrTrRs ������r�add_delegate_accessorsz.delegate_names.<locals>.add_delegate_accessors�s/����#�#�����-�-�
	$�	
��
rr6)rGrQrRrSrFrTr]s`````` r�delegate_namesr^�s���P	�	�"�!rc��eZdZdZdd�Zd�Zy)�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� �||_||_yr5)�_name�	_accessor)rr+rs   r�__init__zCachedAccessor.__init__�s����
�!��rc��|�|jS|j|�}tj||j|�|Sr5)rc�object�__setattr__rb)r�objrP�accessor_objs    r�__get__zCachedAccessor.__get__�s=���;��>�>�!��~�~�c�*��
	���3��
�
�L�9��rN)r+rNrrX)rr r!rErdrjr6rrr`r`�s���&"�
rr`�)�klass�othersc������fd�}|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���rItjdt|��dt���dt���d�tt���t
��t�|���jj��|S)Nzregistration of accessor z under name z
 for type z: is overriding a preexisting attribute with the same name.)�
stacklevel)
r�warnings�warn�repr�UserWarningrrOr`r�add)rrPr+s ��r�	decoratorz%_register_accessor.<locals>.decorator2s{����3����M�M�+�D��N�+;�<���:�,�j��c���40�1��+�-�
�	��T�>�$��9�:������4� ��rr6)r+rPrvs`` r�_register_accessorrw�s���R��r�	DataFrame)rlc�&�ddlm}t||�S)Nr)rx)�pandasrxrw)r+rxs  r�register_dataframe_accessorr{Bs�� ��d�I�.�.r�Seriesc�&�ddlm}t||�S)Nr)r|)rzr|rw)r+r|s  r�register_series_accessorr~Is����d�F�+�+r�Indexc�&�ddlm}t||�S)Nr)r)rzrrw)r+rs  r�register_index_accessorr�Ps����d�E�*�*r)
rQrrRrNrSrVrFrWrTrVrM)rE�
__future__r�typingrrrq�pandas.util._decoratorsr�pandas.util._exceptionsrr	r&r^r`rwr{r~r�r6rr�<module>r�s����#���'�4���<T&�T&�v�-8�!�
3"��3"�

�3"��	3"�
+�3"��
3"�x"�"�J�2�b��U��U�p��{�+�/�,�/���x�(�,�)�,���w�'�+�(�+r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists