403Webshell
Server IP : 209.209.40.120  /  Your IP : 216.73.217.112
Web Server : Microsoft-IIS/10.0
System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586
User : NEWWWW$ ( 0)
PHP Version : 8.3.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Python312/Lib/site-packages/pandas/core/interchange/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Python312/Lib/site-packages/pandas/core/interchange/__pycache__/column.cpython-312.pyc
�

-	�g�D��*�ddlmZddlmZmZddlZddlmZddl	m
Z
ddlmZddl
mZddlmZddlZdd	lmZmZdd
lmZddlmZmZddlmZmZmZmZdd
lm Z m!Z!m"Z"erddlm#Z#ejHejJejLejNejPejRejRd�Z*ejLejVdfejRejXe
fejHejZdfejJejZdfejNejZdfej\ejXdfejPej^dfiZ0ejZdejVdejXdiZ1Gd�de�Z2y)�)�annotations)�
TYPE_CHECKING�AnyN)�infer_dtype)�iNaT)�NoBufferPresent)�cache_readonly)�BaseMaskedDtype)�
ArrowDtype�DatetimeTZDtype)�is_string_dtype)�PandasBuffer�PandasBufferPyarrow)�Column�
ColumnBuffers�ColumnNullType�	DtypeKind)�ArrowCTypes�
Endianness�dtype_to_arrow_c_fmt)�Buffer)�i�u�f�b�U�M�m���zThis column is non-nullablezThis column uses NaN as nullz!This column uses a sentinel valuec���eZdZdZddd�Zdd�Zedd��Zedd��Z	dd�Z
ed��Zed��Zedd	��Z
edd
��Zdd�Zddd
�Zdd�Z		dd�Zdd�Zdd�Zy)�PandasColumna�
    A column object, with only the methods and properties required by the
    interchange protocol defined.
    A column can contain one or more chunks. Each chunk can contain up to three
    buffers - a data buffer, a mask buffer (depending on null representation),
    and an offsets buffer (if variable-size binary; e.g., variable-length
    strings).
    Note: this Column object can only be produced by ``__dataframe__``, so
          doesn't need its own version or ``__column__`` protocol.
    c���t|tj�rtd|j�d���t|tj
�st
dt|��d���||_||_	y)zu
        Note: doesn't deal with extension arrays yet, just assume a regular
        Series/ndarray for now.
        z�Expected a Series, got a DataFrame. This likely happened because you called __dataframe__ on a DataFrame which, after converting column names to string, resulted in duplicated names: zD. Please rename these columns before using the interchange protocol.zColumns of type � not handled yetN)
�
isinstance�pd�	DataFrame�	TypeError�columns�Series�NotImplementedError�type�_col�_allow_copy)�self�column�
allow_copys   �@C:\Python312\Lib\site-packages\pandas/core/interchange/column.py�__init__zPandasColumn.__init__Tsu��
�f�b�l�l�+���!�.�.�)�*2�2��
��&�"�)�)�,�%�(8��f���FV�&W�X�X���	�%���c�.�|jjS)z2
        Size of the column, in elements.
        )r,�size�r.s r1r5zPandasColumn.sizehs���y�y�~�~�r3c��y)z7
        Offset of first element. Always zero.
        r�r6s r1�offsetzPandasColumn.offsetns��r3c��|jj}t|tj�rb|jj
j}|j|j�\}}}}tj||tjfSt|�rMt|j�dvr+tjdt|�tjfSt!d��|j|�S)N)�string�empty�z.Non-string object dtypes are not supported yet)r,�dtyper$r%�CategoricalDtype�values�codes�_dtype_from_pandasdtyper�CATEGORICALr�NATIVEr
r�STRINGrr*)r.r>rA�_�bitwidth�c_arrow_dtype_f_strs      r1r>zPandasColumn.dtypevs����	�	�����e�R�0�0�1��I�I�$�$�*�*�E��,�,�U�[�[�9�
���#���%�%��#��!�!�	�
��U�
#��4�9�9�%�)<�<��$�$��(��/��%�%�	��&�&V�W�W��/�/��6�6r3c���tj|jd�}|�td|�d���t	|t
�r|jj}nZt	|t�r|jj}n3t	|t�r|jj}n|j}|dk(r||jtj|fS||jdzt|�|fS)z/
        See `self.dtype` for details.
        N�
Data type z& not supported by interchange protocolz
bool[pyarrow]r=)�	_NP_KINDS�get�kind�
ValueErrorr$r�numpy_dtype�	byteorderr�baser
�itemsizer�BOOLr)r.r>rMrPs    r1rBz$PandasColumn._dtype_from_pandasdtype�s����}�}�U�Z�Z��.���<��z�%��0V�W�X�X��e�Z�(��)�)�3�3�I�
���
/��
�
�,�,�I�
���
/��)�)�3�3�I����I��O�#������ � ��	�
��U�^�^�a�'�)=�e�)D�i�O�Or3c��|jdtjk(std��|jj
jdttj|jj
j��d�S)a:
        If the dtype is categorical, there are two options:
        - There are only values in the data buffer.
        - There is a separate non-categorical Column encoding for categorical values.

        Raises TypeError if the dtype is not categorical

        Content of returned dict:
            - "is_ordered" : bool, whether the ordering of dictionary indices is
                             semantically meaningful.
            - "is_dictionary" : bool, whether a dictionary-style mapping of
                                categorical values to other objects exists
            - "categories" : Column representing the (implicit) mapping of indices to
                             category values (e.g. an array of cat1, cat2, ...).
                             None if not a dictionary-style categorical.
        rzCdescribe_categorical only works on a column with categorical dtype!T)�
is_ordered�
is_dictionary�
categories)r>rrCr'r,�cat�orderedr!r%r)rWr6s r1�describe_categoricalz!PandasColumn.describe_categorical�si��$�z�z�!�}�	� 5� 5�5��U��
�
�)�)�-�-�/�/�!�&�r�y�y������1I�1I�'J�K�
�	
r3c��t|jjt�rtj
}d}||fSt|jjt�rb|jjjjdj�d�tjdfStjdfS|jd}	t|\}}||fS#t$rtd|�d���wxYw)N�rrJz not yet supported)r$r,r>r
r�USE_BYTEMASKr�array�	_pa_array�chunks�buffers�NON_NULLABLE�USE_BITMASK�_NULL_DESCRIPTION�KeyErrorr*)r.�column_null_dtype�
null_valuerM�null�values      r1�
describe_nullzPandasColumn.describe_null�s����d�i�i�o�o��7� .� ;� ;���J�$�j�0�0��d�i�i�o�o�z�2��y�y���(�(�/�/��2�:�:�<�Q�?�G�%�2�2�D�8�8�!�-�-�q�0�0��z�z�!�}��	M�+�D�1�K�D�%��U�{����	M�%�
�4�&�8J�&K�L�L�	M�s�C!�!C:c�n�|jj�j�j�S)zB
        Number of null elements. Should always be known.
        )r,�isna�sum�itemr6s r1�
null_countzPandasColumn.null_count�s'��
�y�y�~�~��#�#�%�*�*�,�,r3c�2�d|jjiS)z8
        Store specific metadata of the column.
        zpandas.index)r,�indexr6s r1�metadatazPandasColumn.metadata�s��
��	�	���0�0r3c��y)zE
        Return the number of chunks the column consists of.
        r\r8r6s r1�
num_chunkszPandasColumn.num_chunks�s��r3Nc#�K�|rt|dkDrot|j�}||z}||zdk7r|dz
}td||z|�D]4}t|jj|||z|j
����6y|��y�w)zy
        Return an iterator yielding the chunks.
        See `DataFrame.get_chunks` for details on ``n_chunks``.
        r\rN)�lenr,�ranger!�ilocr-)r.�n_chunksr5�step�starts     r1�
get_chunkszPandasColumn.get_chunks�s�����
��1���t�y�y�>�D��8�#�D��h��!�#���	���q�$��/�4�8�
��"��I�I�N�N�5�5�4�<�8�$�:J�:J���
�
�J�s�A<A>c��|j�ddd�}	|j�|d<	|j�|d<|S#t$rY�!wxYw#t$rY|SwxYw)a`
        Return a dictionary containing the underlying buffers.
        The returned dictionary has the following contents:
            - "data": a two-element tuple whose first element is a buffer
                      containing the data and whose second element is the data
                      buffer's associated dtype.
            - "validity": a two-element tuple whose first element is a buffer
                          containing mask values indicating missing data and
                          whose second element is the mask value buffer's
                          associated dtype. None if the null representation is
                          not a bit or byte mask.
            - "offsets": a two-element tuple whose first element is a buffer
                         containing the offset values for variable-size binary
                         data (e.g., variable-length strings) and whose second
                         element is the offsets buffer's associated dtype. None
                         if the data buffer does not have an associated offsets
                         buffer.
        N)�data�validity�offsetsrr�)�_get_data_buffer�_get_validity_bufferr�_get_offsets_buffer)r.ras  r1�get_bufferszPandasColumn.get_bufferss���(�)�)�+���"
��	�"&�";�";�"=�G�J��	�!%�!9�!9�!;�G�I������	��	��
�	����	�s �?�A�	A�
A�	A�Ac���|jdtjtjtjtj
tjfv�rQ|j}|jdtjk(rOt|jd�dkDr4|jjjd�j�}n�|jj}t|jjt�r
|j}ntt|jjt �rD|j"j$d}t'|j)�dt|���}||fS|j*}t-||j.��}||fS|jdtj0k(rV|jj2j4}t-||j.��}|j7|j�}||fS|jdtj8k(r�|jj�}t;�}|D]4}t|t<�s�|j?|jAd�	���6t-tCjD|d
���}|j}||fStGd|jj�d
���)zZ
        Return the buffer containing the data and the buffer's associated dtype.
        r��Nr\��length)r0�utf-8��encoding�uint8)r>rJr#)$r>r�INT�UINT�FLOATrS�DATETIMErvr,�dt�
tz_convert�to_numpyr^r$r
�_datarr_r`rra�_ndarrayrr-rCr@�_codesrBrE�	bytearray�str�extend�encode�np�
frombufferr*)	r.r>�np_arr�arr�bufferrA�bufr�objs	         r1r�zPandasColumn._get_data_buffer0sF���:�:�a�=��M�M��N�N��O�O��N�N����
�
��J�J�E��z�z�!�}�	� 2� 2�2�s�4�:�:�a�=�7I�A�7M������0�0��6�?�?�A���i�i�o�o���d�i�i�o�o��?� �Y�Y�F���	�	����<��-�-�.�.�q�1�C�0����
�a�(�"�3�x��F�"�5�=�(� �\�\�F�!�&�T�5E�5E�F�F�4�u�}��3�Z�Z��]�i�3�3�
3��I�I�$�$�+�+�E�!�%�D�4D�4D�E�F��0�0����=�E�,�u�}��+�Z�Z��]�i�.�.�
.��)�)�$�$�&�C���A��
;���c�3�'��H�H�S�Z�Z��Z�9�:�
;�"�"�-�-���"A�B�F�
�J�J�E��u�}��&�
�4�9�9�?�?�2C�CS�&T�U�Ur3c��|j\}}t|jjt�r�|jj
jjd}tjdtjtjf}|j�d�yt|j�dt|���}||fSt|jjt �r_|jj
j"}t%|�}tjdtjtjf}||fS|jdtj&k(r�|jj)�}|dk(}|}t+j,t|�ft*j.��}t1|�D]\}	}
t|
t2�r|n|||	<�t%|�}tjdtjtjf}||fS	t4|�d�}t;|��#t6$rt9d��wxYw)	z�
        Return the buffer containing the mask values indicating missing data and
        the buffer's associated dtype.
        Raises NoBufferPresent if null representation is not a bit or byte mask.
        rr\Nr�r=��shaper>z! so does not have a separate maskzSee self.describe_null)rjr$r,r>rr^r_r`rrSrrrDrarrvr
�_maskrrEr�r��zeros�bool_�	enumerater��_NO_VALIDITY_BUFFERrer*r)r.rh�invalidr�r>r��maskr��validrr��msgs            r1r�z!PandasColumn._get_validity_bufferns����*�*�
��g��d�i�i�o�o�z�2��)�)�/�/�+�+�2�2�1�5�C��^�^�Q��(8�(8�*�:K�:K�L�E��{�{�}�Q��'��(����
�a� ��3�x��F��5�=� ��d�i�i�o�o��7��9�9�?�?�(�(�D�!�$�'�F��^�^�Q��(8�(8�*�:K�:K�L�E��5�=� ��:�:�a�=�I�,�,�,��)�)�$�$�&�C��q�L�E��i�G��8�8�3�s�8�+�R�X�X�>�D�#�C�.�
E���3�#-�c�3�#7�%�W��Q��
E�
"�$�'�F��^�^�Q��(8�(8�*�:K�:K�L�E��5�=� �	@�(��.�/�/P�Q�C�
�c�"�"��	�	@�%�&>�?�?�	@�s�.I�Ic��|jdtjk(r�|jj	�}d}tjt|�dzft
j��}t|�D]=\}}t|t�r |jd��}|t|�z
}|||dz<�?t|�}tjdtj t"j$f}||fSt'd��)a
        Return the buffer containing the offset values for variable-size binary
        data (e.g., variable-length strings) and the buffer's associated dtype.
        Raises NoBufferPresent if the data buffer does not have an associated
        offsets buffer.
        rr\r�r�r��@zJThis column has a fixed-length dtype so it does not have an offsets buffer)r>rrEr,r�r�r�rv�int64r�r$r�r�rr�r�INT64rrDr)	r.r@�ptrr�r�vrr�r>s	         r1r�z PandasColumn._get_offsets_buffer�s����:�:�a�=�I�,�,�,��Y�Y�'�'�)�F��C��h�h�c�&�k�A�o�%7�r�x�x�H�G�!�&�)�
%���1��a��%����'��2�A��3�q�6�M�C�!$���A���
%�"�'�*�F��
�
���!�!��!�!�	�E��u�}��"�5��
r3)T)r/z	pd.Seriesr0�bool�return�None)r��int)r�ztuple[DtypeKind, int, str, str])r�zdict[str, pd.Index])N)ryz
int | None)r�r)r�z.tuple[Buffer, tuple[DtypeKind, int, str, str]])r�ztuple[Buffer, Any] | None)r�ztuple[PandasBuffer, Any])�__name__�
__module__�__qualname__�__doc__r2r5�propertyr9r	r>rBrZrjrorrrtr|r�r�r�r�r8r3r1r!r!Hs���	�&�(������7��7�:P�B�
��
�8����&�-��-��1��1���"#�J<�	7�<�|7#�r&r3r!)3�
__future__r�typingrr�numpyr��pandas._libs.libr�pandas._libs.tslibsr�
pandas.errorsr�pandas.util._decoratorsr	�pandas.core.dtypes.dtypesr
�pandasr%rr�pandas.api.typesr
�pandas.core.interchange.bufferrr�*pandas.core.interchange.dataframe_protocolrrrr�pandas.core.interchange.utilsrrrrr�r�r�rSrEr�rK�USE_NAN�USE_SENTINELrbrCr]rdr�r!r8r3r1�<module>r�si��"��
�(�$�)�2�5���-�������A�
���	���	���	���	�	�	�	�	�	�	�	�	�
�	��O�O�n�,�,�d�3�
����4�4�d�;�
�M�M�N�/�/��6�
�N�N�^�0�0�$�7�
�N�N�^�0�0�$�7����N�7�7��<�
���~�2�2�A�6������!>����:����!D���E�6�Er3

Youez - 2016 - github.com/yon3zu
LinuXploit