
    q-Ph	                    b    d dl mZ d dlmZmZ d dlmZ d dlmZ	 erd dlm
Z dddddZddZdS )    )annotations)TYPE_CHECKINGAny)get_first_non_none)pyarrow)pandasNT)lengthnan_to_nullvaluespd.Series[Any] | pd.Index[Any]r	   
int | Noner
   boolreturnpa.Arrayc                  t          | dd          }|dk    rt          | j                  }t          |t                    r(t          j        | t          j                    |          S |5t          j        |pt          |           t          j                              S t          j        | |          S |rt          j        | |          S d}t          || j                                                  )a  
    Convert a pandas Series to an Arrow Array.

    Parameters
    ----------
    values : :class:`pandas.Series` or :class:`pandas.Index`.
        Series to convert to arrow
    nan_to_null : bool, default = True
        Interpret `NaN` as missing values.
    length : int, optional
        in case all values are null, create a null array of this length.
        if unset, length is inferred from values.

    Returns
    -------
    :class:`pyarrow.Array`
    dtypeNobject)from_pandaszduplicate column names found: )getattrr   r   
isinstancestrpaarray
large_utf8nullslen
ValueErrorcolumnstolist)r   r	   r
   r   first_non_nonemsgs         `/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/_utils/construction/other.pypandas_series_to_arrowr#      s    . FGT**E+FM::nc** 	D8FBMOOMMMM#8F1c&kk2=??CCCxK8888	 	
xK8888 /~$$&&*
 
 	
    r   c                   ddl m} t          | d          r[| j        dk    rOt          j                            | j                  r*t          j                            | j        j	                  st          j        
                    | j        j	                  s{t          j                            | j        j	                  sRt          j                            | j        j	                  s)t          j                            | j        j	                  r]|                    | t	          j        t	          j                    t	          j                                                                        } | S )z...r   N
num_chunks   )pyarrow.computecomputehasattrr&   r   typesis_dictionarytypeis_int8
index_typeis_uint8is_int16	is_uint16is_int32cast
dictionaryuint32large_stringcombine_chunks)r   pcs     r"   coerce_arrowr:   7   s/         ul## (81(<(< 8!!%*-- 		HUZ233		x  !677		 x  !677		 x!!%*"788			
 x  !677		 GGr}RY[["/2C2CDD n  Lr$   )r   r   r	   r   r
   r   r   r   )r   r   r   r   )
__future__r   typingr   r    polars._utils.construction.utilsr   polars.dependenciesr   r   r   pdr#   r:    r$   r"   <module>rA      s    " " " " " " % % % % % % % % ? ? ? ? ? ? - - - - - - 1000000 	(
 (
 (
 (
 (
 (
V     r$   