Ë
    	êñi­  ã                  óº   — d dl mZ d dlmZ d dlmZmZmZmZ d dl	m
Z
 d dlmZmZmZmZmZ d dlmZ erd dlmZ d dlmZ d d	lmZ d d
lmZmZmZ  G d„ de«      Zy)é    )Úannotations)ÚTYPE_CHECKING)ÚBooleanÚCategoricalÚEnumÚString)ÚPolarsBuffer)ÚColumnÚColumnNullTypeÚCopyNotAllowedErrorÚ	DtypeKindÚ
Endianness)Úpolars_dtype_to_dtype)ÚIterator)ÚAny)ÚSeries)ÚCategoricalDescriptionÚColumnBuffersÚDtypec                  óÔ   — e Zd ZdZddœdd„Zdd„Zedd„«       Zedd„«       Zedd„«       Z	ed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)ÚPolarsColumna6  
    A column object backed by a Polars Series.

    Parameters
    ----------
    column
        The Polars Series backing the column object.
    allow_copy
        Allow data to be copied during operations on this column. If set to `False`,
        a RuntimeError will be raised if data would be copied.
    T©Ú
allow_copyc               ó    — || _         || _        y ©N)Ú_colÚ_allow_copy)ÚselfÚcolumnr   s      ú[/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/polars/interchange/column.pyÚ__init__zPolarsColumn.__init__%   s   € ØˆŒ	Ø%ˆÕó    c                ó6   — | j                   j                  «       S )zSize of the column in elements.)r   Úlen©r   s    r    ÚsizezPolarsColumn.size)   s   € à�y‰y�}‰}‹Ðr"   c                óx   — | j                   j                  t        k(  r| j                   j                  «       d   S y)zOOffset of the first element with respect to the start of the underlying buffer.é   r   )r   Údtyper   Ú_get_buffer_infor%   s    r    ÚoffsetzPolarsColumn.offset-   s/   € ð �9‰9�?‰?œgÒ%Ø—9‘9×-Ñ-Ó/°Ñ2Ð2àr"   c                óD   — | j                   j                  }t        |«      S )zData type of the column.)r   r)   r   )r   Úpl_dtypes     r    r)   zPolarsColumn.dtype5   s   € ð —9‘9—?‘?ˆÜ$ XÓ.Ð.r"   c                ó  — | j                   j                  }|t        k(  r'| j                   j                  j	                  «       }d}n%|t
        k(  r|j                  }d}nd}t        |«      ‚|dt        || j                  ¬«      dœS )z¹
        Description of the categorical data type of the column.

        Raises
        ------
        TypeError
            If the data type of the column is not categorical.
        FTz8`describe_categorical` only works on categorical columnsr   )Ú
is_orderedÚis_dictionaryÚ
categories)
r   r)   r   ÚcatÚget_categoriesr   r1   Ú	TypeErrorr   r   )r   r)   r1   r/   Úmsgs        r    Údescribe_categoricalz!PolarsColumn.describe_categorical;   s|   € ð —	‘	—‘ˆØ”KÒØŸ™Ÿ™×5Ñ5Ó7ˆJØ‰JØ”dŠ]Ø×)Ñ)ˆJØ‰JàLˆCÜ˜C“.Ð ð %Ø!Ü& z¸d×>NÑ>NÔOñ
ð 	
r"   c                óh   — | j                   dk(  rt        j                  dfS t        j                  dfS )z7Description of the null representation the column uses.r   N)Ú
null_countr   ÚNON_NULLABLEÚUSE_BITMASKr%   s    r    Údescribe_nullzPolarsColumn.describe_nullV   s2   € ð �?‰?˜aÒÜ!×.Ñ.°Ð4Ð4ä!×-Ñ-¨qÐ0Ð0r"   c                ó6   — | j                   j                  «       S )zThe number of null elements.)r   r8   r%   s    r    r8   zPolarsColumn.null_count^   s   € ð �y‰y×#Ñ#Ó%Ð%r"   c                ó   — i S )zThe metadata for the column.© r%   s    r    ÚmetadatazPolarsColumn.metadatac   s	   € ð ˆ	r"   c                ó6   — | j                   j                  «       S )z3Return the number of chunks the column consists of.)r   Ún_chunksr%   s    r    Ú
num_chunkszPolarsColumn.num_chunksh   s   € à�y‰y×!Ñ!Ó#Ð#r"   Nc              #  ó¦  K  — | j                  «       }| j                  j                  «       }|�||k(  r!|D ]  }t        || j                  ¬«      –— Œ y|dk  s||z  dk7  rd|› d�}t        |«      ‚||z  }|D ]S  }t        |«      }||z  }||z  dk7  r|dz  }t        d||z  |«      D ]!  }	t        ||	|	|z    | j                  ¬«      –— Œ# ŒU y­w)a  
        Return an iterator yielding the column chunks.

        Parameters
        ----------
        n_chunks
            The number of chunks to return. Must be a multiple of the number of chunks
            in the column.

        Notes
        -----
        When `n_chunks` is higher than the number of chunks in the column, a slice
        must be performed that is not on the chunk boundary. This will trigger some
        compute if the column contains null values or if the column is of data type
        boolean.
        Nr   r   zF`n_chunks` must be a multiple of the number of chunks of this column (ú)r(   )rB   r   Ú
get_chunksr   r   Ú
ValueErrorr$   Úrange)
r   rA   Útotal_n_chunksÚchunksÚchunkr5   Úsubchunks_per_chunkr&   ÚstepÚstarts
             r    rE   zPolarsColumn.get_chunksl   s  è ø€ ð" Ÿ™Ó*ˆØ—‘×%Ñ%Ó'ˆàÐ (¨nÒ"<Øò G�Ü" 5°T×5EÑ5EÔFÓFñGð ˜!Šm ¨NÑ!:¸aÒ!?ðØ#Ð$ Að'ð ô ˜S“/Ð!ð #+¨nÑ"<ÐØò �Ü˜5“z�ØÐ2Ñ2�ØÐ-Ñ-°Ò2Ø˜A‘I�DÜ" 1 dÐ-@Ñ&@À$ÓGò �EÜ&Ø˜e e¨d¡lÐ3À×@PÑ@Pôó ññùs   ‚CCc                ó  — | j                   j                  }|t        k(  r| j                  sd}t	        |«      ‚| j                   j                  «       }| j                  |d   «      | j                  |d   «      | j                  |d   «      dœS )z6Return a dictionary containing the underlying buffers.z string buffers must be convertedÚvaluesÚvalidityÚoffsets)ÚdatarP   rQ   )	r   r)   r   r   r   Ú_get_buffersÚ_wrap_data_bufferÚ_wrap_validity_bufferÚ_wrap_offsets_buffer)r   r)   r5   Úbufferss       r    Úget_bufferszPolarsColumn.get_buffers—   s…   € à—	‘	—‘ˆà”FŠ? 4×#3Ò#3Ø4ˆCÜ% cÓ*Ð*à—)‘)×(Ñ(Ó*ˆð ×*Ñ*¨7°8Ñ+<Ó=Ø×2Ñ2°7¸:Ñ3FÓGØ×0Ñ0°¸Ñ1CÓDñ
ð 	
r"   c                ób   — t        || j                  ¬«      }t        |j                  «      }||fS )Nr   )r	   r   r   r)   ©r   ÚbufferÚinterchange_bufferr)   s       r    rT   zPolarsColumn._wrap_data_buffer§   s.   € Ü)¨&¸T×=MÑ=MÔNÐÜ% f§l¡lÓ3ˆØ! 5Ð(Ð(r"   c                ó‚   — |€y t        || j                  ¬«      }t        j                  ddt        j
                  f}||fS )Nr   r(   Úb)r	   r   r   ÚBOOLr   ÚNATIVErZ   s       r    rU   z"PolarsColumn._wrap_validity_buffer¬   sB   € ð ˆ>Øä)¨&¸T×=MÑ=MÔNÐÜ—‘  C¬×):Ñ):Ð;ˆØ! 5Ð(Ð(r"   c                ó‚   — |€y t        || j                  ¬«      }t        j                  ddt        j
                  f}||fS )Nr   é@   Úl)r	   r   r   ÚINTr   r`   rZ   s       r    rV   z!PolarsColumn._wrap_offsets_buffer¶   sB   € ð ˆ>Øä)¨&¸T×=MÑ=MÔNÐÜ—‘  C¬×):Ñ):Ð;ˆØ! 5Ð(Ð(r"   )r   r   r   ÚboolÚreturnÚNone)rf   Úint)rf   r   )rf   r   )rf   z!tuple[ColumnNullType, int | None])rf   zdict[str, Any]r   )rA   z
int | Nonerf   zIterator[PolarsColumn])rf   r   )r[   r   rf   ztuple[PolarsBuffer, Dtype])r[   zSeries | Nonerf   z!tuple[PolarsBuffer, Dtype] | None)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r!   r&   Úpropertyr+   r)   r6   r;   r8   r?   rB   rE   rX   rT   rU   rV   r>   r"   r    r   r      sÎ   „ ñ
ð >Bõ &óð òó ðð ò/ó ð/ð
 ò
ó ð
ð4 ò1ó ð1ð ò&ó ð&ð òó ðó$ô)óV
ó )ð
)Ø#ð)à	*ó)ð)Ø#ð)à	*ô)r"   r   N)Ú
__future__r   Útypingr   Úpolars.datatypesr   r   r   r   Úpolars.interchange.bufferr	   Úpolars.interchange.protocolr
   r   r   r   r   Úpolars.interchange.utilsr   Úcollections.abcr   r   Úpolarsr   r   r   r   r   r>   r"   r    ú<module>rv      sC   ðÝ "å  ç ?Ó ?Ý 2÷õ õ ;áÝ(ÝåßXÑXôf)�6õ f)r"   