Ë
    ¤eh‹D  ã                  ó*  — 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
 d dlmZ d dlmZ d dlmZ d dlZd d	lmZmZ d d
lmZ d dlmZmZ d dlmZmZmZmZ d dlm Z m!Z!m"Z" erd dlm#Z# ejH                  ejJ                  ejL                  ejN                  ejP                  ejR                  ejR                  dœZ*ejL                  ejV                  dfejR                  ejX                  e
fejH                  ejZ                  dfejJ                  ejZ                  dfejN                  ejZ                  dfej\                  ejX                  dfejP                  ej^                  d fiZ0ejZ                  dejV                  dejX                  diZ1 G d„ de«      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éÿÿÿÿzThis column is non-nullablezThis column uses NaN as nullz!This column uses a sentinel valuec                  óÈ   — e Zd ZdZddd„Zdd„Zedd„«       Zedd„«       Z	dd„Z
ed„ «       Zed„ «       Zedd	„«       Zedd
„«       Zdd„Zddd„Zdd„Z	 	 dd„Zdd„Zdd„Zy)Ú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        |t        j                  «      rt        d|j                  › d�«      ‚t        |t        j
                  «      st        dt        |«      › 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.zColumns of type ú not handled yetN)
Ú
isinstanceÚpdÚ	DataFrameÚ	TypeErrorÚcolumnsÚSeriesÚNotImplementedErrorÚtypeÚ_colÚ_allow_copy)ÚselfÚcolumnÚ
allow_copys      ú\/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/pandas/core/interchange/column.pyÚ__init__zPandasColumn.__init__T   su   € ô
 �fœbŸl™lÔ+Üðð !Ÿ.™.Ð)ð *2ð2óð ô ˜&¤"§)¡)Ô,Ü%Ð(8¼¸f»¸ÐFVÐ&WÓXÐXð ˆŒ	Ø%ˆÕó    c                ó.   — | j                   j                  S )z2
        Size of the column, in elements.
        )r,   Úsize©r.   s    r1   r5   zPandasColumn.sizeh   s   € ð �y‰y�~‰~Ðr3   c                 ó   — y)z7
        Offset of first element. Always zero.
        r   © r6   s    r1   ÚoffsetzPandasColumn.offsetn   s   € ð r3   c                óø  — | j                   j                  }t        |t        j                  «      rb| j                   j
                  j                  }| j                  |j                  «      \  }}}}t        j                  ||t        j                  fS t        |«      rMt        | j                   «      dv r+t        j                  dt        |«      t        j                  fS t!        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   ÚSTRINGr   r*   )r.   r>   rA   Ú_ÚbitwidthÚc_arrow_dtype_f_strs         r1   r>   zPandasColumn.dtypev   sß   € à—	‘	—‘ˆä�eœR×0Ñ0Ô1Ø—I‘I×$Ñ$×*Ñ*ˆEð ×,Ñ,¨U¯[©[Ó9ñØØØ#Øô ×%Ñ%ØØ#Ü×!Ñ!ð	ð ô ˜UÔ#Ü˜4Ÿ9™9Ó%Ð)<Ñ<ä×$Ñ$ØÜ(¨Ó/Ü×%Ñ%ð	ð ô &Ð&VÓWÐWà×/Ñ/°Ó6Ð6r3   c                óä  — t         j                  |j                  d«      }|€t        d|› d�«      ‚t	        |t
        «      r|j                  j                  }nZt	        |t        «      r|j                  j                  }n3t	        |t        «      r|j                  j                  }n|j                  }|dk(  r||j                  t        j                  |fS ||j                  dz  t        |«      |fS )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>   rM   rP   s       r1   rB   z$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ÐOr3   c                ó  — | j                   d   t        j                  k(  st        d«      ‚| j                  j
                  j                  dt        t        j                  | j                  j
                  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.
        r   zCdescribe_categorical only works on a column with categorical dtype!T)Ú
is_orderedÚis_dictionaryÚ
categories)r>   r   rC   r'   r,   ÚcatÚorderedr!   r%   r)   rW   r6   s    r1   Údescribe_categoricalz!PandasColumn.describe_categoricalµ   si   € ð$ �z‰z˜!‰}¤	× 5Ñ 5Ò5ÜØUóð ð
 Ÿ)™)Ÿ-™-×/Ñ/Ø!Ü&¤r§y¡y°·±·±×1IÑ1IÓ'JÓKñ
ð 	
r3   c                óú  — t        | j                  j                  t        «      rt        j
                  }d}||fS t        | j                  j                  t        «      rb| j                  j                  j                  j                  d   j                  «       d   €t        j                  d fS t        j                  dfS | j                  d   }	 t        |   \  }}||fS # t        $ r t        d|› d�«      ‚w xY w)Né   r   rJ   z 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_nullzPandasColumn.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   — | j                   j                  «       j                  «       j                  «       S )zB
        Number of null elements. Should always be known.
        )r,   ÚisnaÚsumÚitemr6   s    r1   Ú
null_countzPandasColumn.null_countæ   s'   € ð
 �y‰y�~‰~Ó×#Ñ#Ó%×*Ñ*Ó,Ð,r3   c                ó2   — d| j                   j                  iS )z8
        Store specific metadata of the column.
        zpandas.index)r,   Úindexr6   s    r1   ÚmetadatazPandasColumn.metadataí   s   € ð
  §	¡	§¡Ð0Ð0r3   c                 ó   — y)zE
        Return the number of chunks the column consists of.
        r\   r8   r6   s    r1   Ú
num_chunkszPandasColumn.num_chunksô   s   € ð r3   Nc              #  ó   K  — |rt|dkD  rot        | j                  «      }||z  }||z  dk7  r|dz  }t        d||z  |«      D ]4  }t        | j                  j                  |||z    | j
                  «      –— Œ6 y| –— y­w)zy
        Return an iterator yielding the chunks.
        See `DataFrame.get_chunks` for details on ``n_chunks``.
        r\   r   N)Úlenr,   Úranger!   Úilocr-   )r.   Ún_chunksr5   ÚstepÚstarts        r1   Ú
get_chunkszPandasColumn.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                  «       dddœ}	 | j                  «       |d<   	 | j                  «       |d<   |S # t        $ r Y Œ!w xY w# t        $ r Y |S w xY w)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Úoffsetsr   r€   )Ú_get_data_bufferÚ_get_validity_bufferr   Ú_get_offsets_buffer)r.   ra   s     r1   Úget_bufferszPandasColumn.get_buffers  s€   € ð( ×)Ñ)Ó+ØØñ"
ˆð	Ø"&×";Ñ";Ó"=ˆG�JÑð	Ø!%×!9Ñ!9Ó!;ˆG�IÑð ˆøô ò 	Ùð	ûô
 ò 	Øàˆð	ús    –? ªA ¿	AÁ
AÁ	AÁAc                óê  — | j                   d   t        j                  t        j                  t        j                  t        j
                  t        j                  fv �rQ| j                   }| j                   d   t        j                  k(  rOt        | j                   d   «      dkD  r4| j                  j                  j                  d«      j                  «       }n»| j                  j                  }t        | j                  j                   t        «      r|j                  }ntt        | j                  j                   t         «      rD|j"                  j$                  d   }t'        |j)                  «       d   t        |«      ¬«      }||fS |j*                  }t-        || j.                  ¬«      }||fS | j                   d   t        j0                  k(  rV| j                  j2                  j4                  }t-        || j.                  ¬«      }| j7                  |j                   «      }||fS | j                   d   t        j8                  k(  r�| j                  j                  «       }t;        «       }|D ]4  }t        |t<        «      sŒ|j?                  |jA                  d¬	«      «       Œ6 t-        tC        jD                  |d
¬«      «      }| j                   }||fS tG        d| j                  j                   › d�«      ‚)zZ
        Return the buffer containing the data and the buffer's associated dtype.
        r   é   é   Nr\   ©Úlength)r0   úutf-8©ÚencodingÚuint8)r>   rJ   r#   )$r>   r   ÚINTÚUINTÚFLOATrS   ÚDATETIMErv   r,   ÚdtÚ
tz_convertÚto_numpyr^   r$   r
   Ú_datar   r_   r`   r   ra   Ú_ndarrayr   r-   rC   r@   Ú_codesrB   rE   Ú	bytearrayÚstrÚextendÚencodeÚnpÚ
frombufferr*   )	r.   r>   Únp_arrÚarrÚbufferrA   Úbufr   Úobjs	            r1   r�   zPandasColumn._get_data_buffer0  sF  € ð �:‰:�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ÐUr3   c                óº  — | j                   \  }}t        | j                  j                  t        «      rœ| j                  j
                  j                  j                  d   }t        j                  dt        j                  t        j                  f}|j                  «       d   €yt        |j                  «       d   t        |«      ¬«      }||fS t        | j                  j                  t         «      r_| j                  j
                  j"                  }t%        |«      }t        j                  dt        j                  t        j                  f}||fS | j                  d   t        j&                  k(  rº| j                  j)                  «       }|dk(  }| }t+        j,                  t        |«      ft*        j.                  ¬«      }t1        |«      D ]  \  }	}
t        |
t2        «      r|n|||	<   Œ t%        |«      }t        j                  dt        j                  t        j                  f}||fS 	 t4        |   › d�}t;        |«      ‚# t6        $ r t9        d«      ‚w xY w)	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.
        r   r\   Nrˆ   r=   ©Úshaper>   z! so does not have a separate maskzSee self.describe_null)rj   r$   r,   r>   r   r^   r_   r`   r   rS   r   r   rD   ra   r   rv   r
   Ú_maskr   rE   r”   rœ   ÚzerosÚbool_Ú	enumerater™   Ú_NO_VALIDITY_BUFFERre   r*   r   )r.   rh   ÚinvalidrŸ   r>   r    Úmaskr¡   Úvalidr   r¢   Úmsgs               r1   r‚   z!PandasColumn._get_validity_buffern  s÷  € ð ×*Ñ*‰ˆˆ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 ÉIc                ó  — | j                   d   t        j                  k(  rØ| j                  j	                  «       }d}t        j                  t        |«      dz   ft
        j                  ¬«      }t        |«      D ]=  \  }}t        |t        «      r |j                  d¬«      }|t        |«      z  }|||dz   <   Œ? t        |«      }t        j                  dt        j                   t"        j$                  f}||fS t'        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.
        r   r\   r¤   rŠ   r‹   é@   zJThis column has a fixed-length dtype so it does not have an offsets buffer)r>   r   rE   r,   r”   rœ   r§   rv   Úint64r©   r$   r™   r›   r   rŽ   r   ÚINT64r   rD   r   )	r.   r@   Úptrr€   r   Úvr   r    r>   s	            r1   rƒ   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¶   ztuple[DtypeKind, int, str, str])r¶   zdict[str, pd.Index])N)ry   z
int | None)r¶   r   )r¶   z.tuple[Buffer, tuple[DtypeKind, int, str, str]])r¶   ztuple[Buffer, Any] | None)r¶   ztuple[PandasBuffer, Any])Ú__name__Ú
__module__Ú__qualname__Ú__doc__r2   r5   Úpropertyr9   r	   r>   rB   rZ   rj   ro   rr   rt   r|   r„   r�   r‚   rƒ   r8   r3   r1   r!   r!   H   s¹   „ ñ	ô&ó(ð òó ðð ò7ó ð7ó:PðB ñ
ó ð
ð8 ñó ðð& ò-ó ð-ð ò1ó ð1óôó"#ðJ<à	7ó<ó|7#ôr&r3   r!   )3Ú
__future__r   Útypingr   r   Únumpyrœ   Úpandas._libs.libr   Úpandas._libs.tslibsr   Úpandas.errorsr   Úpandas.util._decoratorsr	   Úpandas.core.dtypes.dtypesr
   Úpandasr%   r   r   Úpandas.api.typesr   Úpandas.core.interchange.bufferr   r   Ú*pandas.core.interchange.dataframe_protocolr   r   r   r   Úpandas.core.interchange.utilsr   r   r   r   rŽ   r�   r�   rS   rE   r‘   rK   ÚUSE_NANÚUSE_SENTINELrb   rC   r]   rd   rª   r!   r8   r3   r1   ú<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õ Er3   