Ë
    čËhW ă                  ó`   d dl mZ d dlmZmZmZ d dlmZ d dl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 d dlmZ d d	lmZmZ d d
lmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z% d dl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, d dl-m.Z. er:d dl/Z/d dlm0Z0 d dlm1Z1m2Z2 d dl3m4Z4m5Z5m6Z6m7Z7 e/jp                  dk\  rd dlm9Z9 nd dl:m9Z9 g d˘Z;edDdŤ       Z<edEdŤ       Z<dFdZ<dd	 	 	 	 	 	 	 dGdZ=dHdZ>dd	 	 	 	 	 	 	 	 	 	 	 dIdZ?	 	 	 	 	 	 dJdZ@ G d  de.Ť      ZAdd!dKd"ZBdLd#ZCdMdd$dNd%ZD	 dMdd$	 	 	 	 	 dNd&ZEdLd'ZFdLd(ZG	 	 	 	 dOd)ZHdPd*ZIdd+dQd,ZJdLd-ZKdRd.ZLdLd/ZM	 	 dS	 	 	 	 	 dTd0ZdLd1ZNdMdUd2ZO	 dV	 	 	 dWd3ZPdXd4ZQ	 	 	 	 	 	 dYd5ZRdLd6ZSdLd7ZTdLd8ZUdLd9ZVdLd:ZWdLd;ZXdZd<ZYdLd=ZZdLd>Z[d[d?Z\dd@d\dAZ]dLdBZ^dLdCZ_y)]é    )Úannotations)Ú
CollectionÚMappingÚSequence)Útimezone)Úreduce)Úor_)ÚTYPE_CHECKINGÚAnyÚLiteralÚNoReturnÚoverload)Ú	functions)Ú_parse_inputs_as_iterable)Ú	is_columnÚ	re_escape)ÚBinaryÚBooleanÚCategoricalÚDateÚDatetimeÚDecimalÚDurationÚObjectÚStringÚTimeÚis_polars_dtype)ÚFLOAT_DTYPESÚINTEGER_DTYPESÚNUMERIC_DTYPESÚSIGNED_INTEGER_DTYPESÚTEMPORAL_DTYPESÚUNSIGNED_INTEGER_DTYPES)ÚExprN)ÚIterable)Ú	DataFrameÚ	LazyFrame)ÚPolarsDataTypeÚPythonDataTypeÚSelectorTypeÚTimeUnit)é   é   )ÚSelf)ÚallÚalphaÚalphanumericÚbinaryÚbooleanÚby_dtypeÚby_indexÚby_nameÚcategoricalÚcontainsÚdateÚdatetimeÚdecimalÚdigitÚdurationÚ	ends_withÚexcludeÚexpand_selectorÚfirstÚfloatÚintegerÚis_selectorÚlastÚmatchesÚnumericÚsigned_integerÚstarts_withÚstringÚtemporalÚtimeÚunsigned_integerÚ_selector_proxy_c                 ó    y ŠNŠ ŠÚobjs    úl/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/polars/selectors.pyrD   rD   X   s    Ř9<ó    c                 ó    y rP   rQ   rR   s    rT   rD   rD   \   s    Ř-0rU   c                ó>    t        | t        Ť      xr t        | dŤ      S )a  
    Indicate whether the given object/expression is a selector.

    Examples
    --------
    >>> from polars.selectors import is_selector
    >>> import polars.selectors as cs
    >>> is_selector(pl.col("colx"))
    False
    >>> is_selector(cs.first() | cs.last())
    True
    Ú_attrs)Ú
isinstancerN   ÚhasattrrR   s    rT   rD   rD   `   s    ô cÔ+Ó,ŇG´¸¸hÓ1GĐGrU   T)Ústrictc               ó   t        | t        Ť      rddlm}  || ŹŤ      } |rt	        |Ť      s.n|j
                  j                  dŹŤ      sd|d}t        |Ť      t        | j                  |Ť      j                  Ť       Ť      S )ax  
    Expand selector to column names, with respect to a specific frame or target schema.

    .. versionadded:: 0.20.30
        The `strict` parameter was added.

    Parameters
    ----------
    target
        A Polars DataFrame, LazyFrame or Schema.
    selector
        An arbitrary polars selector (or compound selector).
    strict
        Setting False additionally allows for a broader range of column selection
        expressions (such as bare columns or use of `.exclude()`) to be expanded,
        not just the dedicated selectors.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "colx": ["a", "b", "c"],
    ...         "coly": [123, 456, 789],
    ...         "colz": [2.0, 5.5, 8.0],
    ...     }
    ... )

    Expand selector with respect to an existing `DataFrame`:

    >>> cs.expand_selector(df, cs.numeric())
    ('coly', 'colz')
    >>> cs.expand_selector(df, cs.first() | cs.last())
    ('colx', 'colz')

    This also works with `LazyFrame`:

    >>> cs.expand_selector(df.lazy(), ~(cs.first() | cs.last()))
    ('coly',)

    Expand selector with respect to a standalone `Schema` dict:

    >>> schema = {
    ...     "id": pl.Int64,
    ...     "desc": pl.String,
    ...     "count": pl.UInt32,
    ...     "value": pl.Float64,
    ... }
    >>> cs.expand_selector(schema, cs.string() | cs.float())
    ('desc', 'value')

    Allow for non-strict selection expressions (such as those
    including use of an `.exclude()` constraint) to be expanded:

    >>> cs.expand_selector(schema, cs.numeric().exclude("id"), strict=False)
    ('count', 'value')
    r   )r&   )ÚschemaF)Úallow_aliasingzexpected a selector; found ú	 instead.)rY   r   Úpolars.dataframer&   rD   ÚmetaÚis_column_selectionÚ	TypeErrorÚtupleÚselectÚcollect_schema)ÚtargetÚselectorr[   r&   Úmsgs        rT   r@   r@   s   su    ô~ &'Ô"Ý.á &Ô)ń ô 	HŐŕ]]×.Ń.¸eĐ.ÔDŕ+¨H¨<°yĐAÜnĐäxÓ(×7Ń7Ó9Ó:Đ:rU   c                ó˘    t        |Ť      }g }|D ]<  }t        |Ť      rt        | |Ť      }|j                  |Ť       ,|j	                  |Ť       > |S )as  
    Internal function that expands any selectors to column names in the given input.

    Non-selector values are left as-is.

    Examples
    --------
    >>> from polars.selectors import _expand_selectors
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "colw": ["a", "b"],
    ...         "colx": ["x", "y"],
    ...         "coly": [123, 456],
    ...         "colz": [2.0, 5.5],
    ...     }
    ... )
    >>> _expand_selectors(df, ["colx", cs.numeric()])
    ['colx', 'coly', 'colz']
    >>> _expand_selectors(df, cs.string(), cs.float())
    ['colw', 'colx', 'colz']
    )r   rD   r@   ÚextendÚappend)ÚframeÚitemsÚ
items_iterÚexpandedÚitemÚselector_colss         rT   Ú_expand_selectorsrs   Ä   sU    ô. +¨5Ó1JŕHŘň "ÜtÔÜ+¨E°4Ó8MŘOOMŐ*ŕOODŐ!đ"đ OrU   F)Ú
tuple_keysc               ó    i }|xs i j                  Ť       D ]t  \  }}|r t        |Ť      rt        | |ŹŤ      ||<   ||   }|rFt        |Ť      r;t        | |ŹŤ      }|r|||<   J|j                  t        j                  ||Ť      Ť       p|||<   v |S )zCExpand dict key/value selectors into their underlying column names.)rh   )rn   rD   r@   ÚupdateÚdictÚfromkeys)	ÚdfÚdÚexpand_keysÚexpand_valuesrt   rp   ÚkeyÚvalueÚcolss	            rT   Ú_expand_selector_dictsr   ç   s    đ HŘwBooÓ'ň "
UŮ[¨Ô/Ü+¨B¸Ô?HSMŘSMEŮ; sÔ+Ü" 2°Ô4DŮŘ!&ŕ¤§Ą¨d°EÓ :Ő;ŕ!HSMđ"đ OrU   c                óX   g g g g f\  }}}}g t        | t        Ť      rt        | t        Ť      s| n| g˘|˘­D ]×  }t        |Ť      r|j	                  |Ť        t        |Ť      r|j	                  |Ť       =t        |t        Ť      rF|j                  dŤ      r#|j                  dŤ      r|j	                  |Ť       |j	                  |Ť       t        |Ť      r*|j	                  |j                  j                  Ť       Ť       Čd|d}t        |Ť       g }|r|j	                  t        | Ť       |r|j	                  t        | Ť       |rC|j	                  t        t        |Ť      dkD  rdj!                  d |D Ť       Ť      n|d   Ť      Ť       |r|j#                  |Ť       t%        t&        |Ť      S )	zLCreate a combined selector from cols, names, dtypes, and/or other selectors.ú^ú$z:expected one or more `str`, `DataType` or selector; found r_   é   ú|c              3  ó(   K   | ]
  }d | d  y­w)ú(ú)NrQ   )Ú.0Úrxs     rT   ú	<genexpr>z'_combine_as_selector.<locals>.<genexpr>+  s   č ř Ň5 r1RD Ń5ůs   r   )rY   r   ÚstrrD   rl   r   Ú
startswithÚendswithr   ra   Úoutput_namerc   r6   r4   rF   ÚlenÚjoinrk   r   r	   )	rn   Ú
more_itemsÚnamesÚregexesÚdtypesÚ	selectorsrq   ri   Úselecteds	            rT   Ú_combine_as_selectorr      s   đ )+¨B°°B¨Ń%E7FIđô %¤Ô,´ZŔÄsÔ5Kń ŕđ	đ 
ńň !ô tÔŘ×ŃTŐ"ÜTÔ"ŘMM$ŐÜcÔ"ŘsÔ#¨ŻŠ°cÔ(:ŘtŐ$ŕTŐ"Üt_ŘLL×.Ń.Ó0Ő1ŕNČtČhĐV_Đ`CÜC.Đ đ+!đ. HŮŘ Ô(ŮŘ &Đ)Ô*ŮŘÜäw< !Ň#đ Ń5¨WÔ5Ô5ŕQZóô	
ń Ř	Ô"ä#xÓ Đ rU   c                  ód   e Zd ZU dZded<   ded<   	 d 	 	 	 	 	 	 	 d!dZd"dZd#d	Zd$d
Ze	d%dŤ       Z
e	d&dŤ       Z
d'dZ
d&dZe	d%dŤ       Ze	d&dŤ       Zd'dZd&dZe	d%dŤ       Ze	d&dŤ       Zd'dZd&dZe	d%dŤ       Ze	d'dŤ       Zd&dZd(dZe	d%dŤ       Ze	d&dŤ       Zd'dZd&dZd)dZy)*rN   z&Base column selector expression/proxy.údict[str, Any]rX   r   Ú_repr_overrideNc                ó:    |j                   | _         ||d| _        y )N)ÚparamsÚname)Ú_pyexprrX   )ÚselfÚexprr   Ú
parameterss       rT   Ú__init__z_selector_proxy_.__init__<  s    đ ||ŕ Řń
rU   c                ó*    t        t        | Ť      Ť      S rP   )ÚhashÚreprŠr    s    rT   Ú__hash__z_selector_proxy_.__hash__H  s    ô DJÓĐrU   c                óp    t        | Ť      rt        Ť       | z
  }d| |_        |S | j                  Ť        }|S )zInvert the selector.ú~)rD   r/   r   Úas_expr)r    Úinverteds     rT   Ú
__invert__z_selector_proxy_.__invert__M  s>    ätÔÜut|HŘ()¨$¨ lHÔ#đ đ HŘrU   c                óÎ   t        | dŤ      st        | j                  Ť       Ť      S t        | dŤ      r| j                  S | j                  d   | j                  d   xs i }}ddddd	}||v r>||   }d
j                  d| dj                  d |j                  Ť       D Ť       Ť      Ť      S dj                  d |j                  Ť       D Ť       Ť      j                  dŤ      }d| d| dS )NrX   r   r   r   ú&r   ú-r   )ÚandÚorÚsubÚxorz({})ú c              3  ó2   K   | ]  }t        |Ť        y ­wrP   )rŚ   )r   Úps     rT   r   z,_selector_proxy_.__repr__.<locals>.<genexpr>`  s   č ř Ň3UŔ´D¸ˇGŃ3Uůó   z, c              3  ón   K   | ]-  \  }}|j                  d Ť      rt        |Ť      dd n| d| / y­w)Ú*r   é˙˙˙˙ú=N)r   rŚ   )r   ÚkÚvs      rT   r   z,_selector_proxy_.__repr__.<locals>.<genexpr>b  s@   č ř ň 'á1đ '(§lĄl°3Ô&7T!WQr]Ŕ¸sŔ!ŔAŔ5¸\ÓIń'ůs   35ú,zcs.r   r   )
rZ   rŚ   rŤ   r   rX   Úformatr   Úvaluesrn   Úrstrip)r    Úselector_namer   Úset_opsÚopÚ
str_paramss         rT   Ú__repr__z_selector_proxy_.__repr__V  sç    ÜtXÔ&ÜÓ'Đ'ÜTĐ+Ô,Ř×&Ń&Đ&ŕ$(§KĄK°Ń$7¸żšŔXŃ9NŇ9TĐRT6MŘ!¨°SŔŃEGŘ Ń'Ř]Ń+Ř}} q¨¨¨A Y§^Ą^Ń3UŔVÇ]Á]Ă_Ô3UÓ%UÓVĐVŕ!YYń 'ŕ &§ĄŁô'ó ÷ &+đ đ ]O¨1¨Z¨L¸Đ:Đ:rU   c                 ó    y rP   rQ   Šr    Úothers     rT   Ú__add__z_selector_proxy_.__add__h  ó    Ř<?rU   c                 ó    y rP   rQ   rÉ   s     rT   rË   z_selector_proxy_.__add__k  ó    Ř+.rU   c                óp    t        |Ť      rd}t        |Ť      | j                  Ť       j                  |Ť      S )Nz=unsupported operand type(s) for op: ('Selector' + 'Selector'))rD   rc   rŤ   rË   Šr    rĘ   ri   s      rT   rË   z_selector_proxy_.__add__n  s0    ÜuÔŘQCÜC.Đ ŕ<<>×)Ń)¨%Ó0Đ0rU   c                ó    d}t        |Ť      )Nz9unsupported operand type(s) for op: ('Expr' + 'Selector')Šrc   rĐ   s      rT   Ú__radd__z_selector_proxy_.__radd__u  ó    ŘIÜnĐrU   c                 ó    y rP   rQ   rÉ   s     rT   Ú__and__z_selector_proxy_.__and__y  rĚ   rU   c                 ó    y rP   rQ   rÉ   s     rT   rÖ   z_selector_proxy_.__and__|  rÎ   rU   c                ó:   t        |Ť      r%|j                  j                  Ť       }t        |Ť      }t	        |Ť      rBt        | j                  j                  Ť       j                  j                  |Ť      | |ddŹŤ      S | j                  Ť       j                  |Ť      S )NrÉ   rą   Šr˘   r   )
r   ra   r   r6   rD   rN   Ú_as_selectorÚ_selector_andrŤ   rÖ   Šr    rĘ   Úcolnames      rT   rÖ   z_selector_proxy_.__and__  s    ÜUÔŘjj×,Ń,Ó.GÜGÓ$EÜuÔÜ#Ř		×&Ń&Ó(×-Ń-×;Ń;¸EÓBŘ$(°5Ń9Řôđ đ <<>×)Ń)¨%Ó0Đ0rU   c                óŚ    t        |Ť      r(|j                  j                  Ť       }t        |Ť      | z  S | j	                  Ť       j                  |Ť      S rP   )r   ra   r   r6   rŤ   Ú__rand__rÜ   s      rT   rß   z_selector_proxy_.__rand__  sC    ÜUÔŘjj×,Ń,Ó.GÜ7Ó# dŃ*Đ*Ř||~×&Ń& uÓ-Đ-rU   c                 ó    y rP   rQ   rÉ   s     rT   Ú__or__z_selector_proxy_.__or__  s    Ř;>rU   c                 ó    y rP   rQ   rÉ   s     rT   rá   z_selector_proxy_.__or__  s    Ř*-rU   c                ó6   t        |Ť      r#t        |j                  j                  Ť       Ť      }t	        |Ť      rBt        | j                  j                  Ť       j                  j                  |Ť      | |ddŹŤ      S | j                  Ť       j                  |Ť      S )NrÉ   r˛   rŮ   )
r   r6   ra   r   rD   rN   rÚ   Ú_selector_addrŤ   rá   rÉ   s     rT   rá   z_selector_proxy_.__or__  s{    ÜUÔÜEJJ×2Ń2Ó4Ó5EÜuÔÜ#Ř		×&Ń&Ó(×-Ń-×;Ń;¸EÓBŘ$(°5Ń9Řôđ đ <<>×(Ń(¨Ó/Đ/rU   c                ó    t        |Ť      r#t        |j                  j                  Ť       Ť      }| j	                  Ť       j                  |Ť      S rP   )r   r6   ra   r   rŤ   Ú__ror__rÉ   s     rT   rć   z_selector_proxy_.__ror__¤  s8    ÜUÔÜEJJ×2Ń2Ó4Ó5EŘ||~×%Ń% eÓ,Đ,rU   c                 ó    y rP   rQ   rÉ   s     rT   Ú__sub__z_selector_proxy_.__sub__Š  rĚ   rU   c                 ó    y rP   rQ   rÉ   s     rT   rč   z_selector_proxy_.__sub__Ź  s    Ř:=rU   c                óÚ    t        |Ť      rBt        | j                  j                  Ť       j                  j	                  |Ť      | |ddŹŤ      S | j                  Ť       j                  |Ť      S )NrÉ   rł   rŮ   )rD   rN   ra   rÚ   Ú_selector_subrŤ   rč   rÉ   s     rT   rč   z_selector_proxy_.__sub__Ż  s\    ÜuÔÜ#Ř		×&Ń&Ó(×-Ń-×;Ń;¸EÓBŘ$(°5Ń9Řôđ đ <<>×)Ń)¨%Ó0Đ0rU   c                ó    d}t        |Ť      )Nz9unsupported operand type(s) for op: ('Expr' - 'Selector')rŇ   rĐ   s      rT   Ú__rsub__z_selector_proxy_.__rsub__š  rÔ   rU   c                 ó    y rP   rQ   rÉ   s     rT   Ú__xor__z_selector_proxy_.__xor__˝  rĚ   rU   c                 ó    y rP   rQ   rÉ   s     rT   rď   z_selector_proxy_.__xor__Ŕ  rÎ   rU   c                ó6   t        |Ť      r#t        |j                  j                  Ť       Ť      }t	        |Ť      rBt        | j                  j                  Ť       j                  j                  |Ť      | |ddŹŤ      S | j                  Ť       j                  |Ť      S )NrÉ   r´   rŮ   )
r   r6   ra   r   rD   rN   rÚ   Ú_selector_xorrŤ   rď   rÉ   s     rT   rď   z_selector_proxy_.__xor__Ă  s{    ÜUÔÜEJJ×2Ń2Ó4Ó5EÜuÔÜ#Ř		×&Ń&Ó(×-Ń-×;Ń;¸EÓBŘ$(°5Ń9Řôđ đ <<>×)Ń)¨%Ó0Đ0rU   c                ó    t        |Ť      r#t        |j                  j                  Ť       Ť      }| j	                  Ť       j                  |Ť      S rP   )r   r6   ra   r   rŤ   Ú__rxor__rÉ   s     rT   rô   z_selector_proxy_.__rxor__Ď  s8    ÜUÔÜEJJ×2Ń2Ó4Ó5EŘ||~×&Ń& uÓ-Đ-rU   c                ó@    t        j                  | j                  Ť      S )u  
        Materialize the `selector` as a normal expression.

        This ensures that the operators `|`, `&`, `~` and `-`
        are applied on the data and not on the selector sets.

        Examples
        --------
        >>> import polars.selectors as cs
        >>> df = pl.DataFrame(
        ...     {
        ...         "colx": ["aa", "bb", "cc"],
        ...         "coly": [True, False, True],
        ...         "colz": [1, 2, 3],
        ...     }
        ... )

        Inverting the boolean selector will choose the non-boolean columns:

        >>> df.select(~cs.boolean())
        shape: (3, 2)
        ââââââââŹâââââââ
        â colx â colz â
        â ---  â ---  â
        â str  â i64  â
        ââââââââŞâââââââĄ
        â aa   â 1    â
        â bb   â 2    â
        â cc   â 3    â
        ââââââââ´âââââââ

        To invert the *values* in the selected boolean columns, we need to
        materialize the selector as a standard expression instead:

        >>> df.select(~cs.boolean().as_expr())
        shape: (3, 1)
        âââââââââ
        â coly  â
        â ---   â
        â bool  â
        âââââââââĄ
        â false â
        â true  â
        â false â
        âââââââââ
        )r$   Ú_from_pyexprr   r§   s    rT   rŤ   z_selector_proxy_.as_exprÔ  s    ô^ × Ń  §ĄÓ.Đ.rU   rP   )rĄ   r$   r   r   r˘   zdict[str, Any] | NoneÚreturnÚNone)r÷   Úint)r÷   r.   )r÷   r   )rĘ   r*   r÷   r*   )rĘ   r   r÷   r$   )rĘ   r   r÷   úSelectorType | Expr)rĘ   r   r÷   r   )r÷   r$   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__rŁ   r¨   r­   rÇ   r   rË   rÓ   rÖ   rß   rá   rć   rč   rí   rď   rô   rŤ   rQ   rU   rT   rN   rN   6  s   Ů0ŕÓŘÓđ -1đ	

ŕđ

đ đ

đ *đ	

đ
 
ó

ó ó
ó;đ$ Ú?ó Ř?ŕÚ.ó Ř.ó1óđ Ú?ó Ř?ŕÚ.ó Ř.ó1ó.đ Ú>ó Ř>ŕÚ-ó Ř-ó
0ó-đ
 Ú?ó Ř?ŕÚ=ó Ř=ó1óđ Ú?ó Ř?ŕÚ.ó Ř.ó
1ó.ô
//rU   )Úescapec               ó   t        | t        Ť      rrt        | Ť      n| }nfg }| D ]E  }t        |t        Ť      r"t        |t        Ť      s|j	                  |Ť       5|j                  |Ť       G dj                  fd|D Ť       Ť      }d| dS )zIReturn escaped regex, potentially representing multiple string fragments.r   c              3  ó<   K   | ]  }rt        |Ť      n|  y ­wrP   Šr   )r   Úxr   s     rT   r   z_re_string.<locals>.<genexpr>  s   řč ř ŇG¸!Ąvy |°1Ó4ŃGůs   r   r   )rY   r   r   r   rk   rl   r   )rJ   r   r   ÚstringsÚsts    `   rT   Ú
_re_stringr    s~   ř ä&#ÔŮ"(YvÔ¨fŕŘň 	#BÜ"jÔ)´*¸RÄÔ2EŘrŐ"ŕrŐ"đ		#đ
 XXÓG¸wÔGÓGŘrd!9ĐrU   c                 ó@    t        t        j                  Ť       dŹŤ      S )uz  
    Select all columns.

    See Also
    --------
    first : Select the first column in the current scope.
    last : Select the last column in the current scope.

    Examples
    --------
    >>> from datetime import date
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "dt": [date(1999, 12, 31), date(2024, 1, 1)],
    ...         "value": [1_234_500, 5_000_555],
    ...     },
    ...     schema_overrides={"value": pl.Int32},
    ... )

    Select all columns, casting them to string:

    >>> df.select(cs.all().cast(pl.String))
    shape: (2, 2)
    ââââââââââââââŹââââââââââ
    â dt         â value   â
    â ---        â ---     â
    â str        â str     â
    ââââââââââââââŞââââââââââĄ
    â 1999-12-31 â 1234500 â
    â 2024-01-01 â 5000555 â
    ââââââââââââââ´ââââââââââ

    Select all columns *except* for those matching the given dtypes:

    >>> df.select(cs.all() - cs.numeric())
    shape: (2, 1)
    ââââââââââââââ
    â dt         â
    â ---        â
    â date       â
    ââââââââââââââĄ
    â 1999-12-31 â
    â 2024-01-01 â
    ââââââââââââââ
    r/   Šr   )rN   ÚFr/   rQ   rU   rT   r/   r/     s    ô^ AEEG¨%Ô0Đ0rU   )Úignore_spacesc               ón    | rdnd}|rdnd}t        t        j                  d| | dŤ      d| |dŹ	Ť      S )
uW  
    Select all columns with alphabetic names (eg: only letters).

    Parameters
    ----------
    ascii_only
        Indicate whether to consider only ASCII alphabetic characters, or the full
        Unicode range of valid letters (accented, idiographic, etc).
    ignore_spaces
        Indicate whether to ignore the presence of spaces in column names; if so,
        only the other (non-space) characters are considered.

    Notes
    -----
    Matching column names cannot contain *any* non-alphabetic characters. Note
    that the definition of "alphabetic" consists of all valid Unicode alphabetic
    characters (`\p{Alphabetic}`) by default; this can be changed by setting
    `ascii_only=True`.

    Examples
    --------
    >>> import polars as pl
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "no1": [100, 200, 300],
    ...         "cafĂŠ": ["espresso", "latte", "mocha"],
    ...         "t or f": [True, False, None],
    ...         "hmm": ["aaa", "bbb", "ccc"],
    ...         "é˝ĺ¸": ["ćąäşŹ", "ĺ¤§éŞ", "äşŹé˝"],
    ...     }
    ... )

    Select columns with alphabetic names; note that accented
    characters and kanji are recognised as alphabetic here:

    >>> df.select(cs.alpha())
    shape: (3, 3)
    ââââââââââââŹââââââŹâââââââ
    â cafĂŠ     â hmm â é˝ĺ¸ â
    â ---      â --- â ---  â
    â str      â str â str  â
    ââââââââââââŞââââââŞâââââââĄ
    â espresso â aaa â ćąäşŹ â
    â latte    â bbb â ĺ¤§éŞ â
    â mocha    â ccc â äşŹé˝ â
    ââââââââââââ´ââââââ´âââââââ

    Constrain the definition of "alphabetic" to ASCII characters only:

    >>> df.select(cs.alpha(ascii_only=True))
    shape: (3, 1)
    âââââââ
    â hmm â
    â --- â
    â str â
    âââââââĄ
    â aaa â
    â bbb â
    â ccc â
    âââââââ

    >>> df.select(cs.alpha(ascii_only=True, ignore_spaces=True))
    shape: (3, 2)
    ââââââââââŹââââââ
    â t or f â hmm â
    â ---    â --- â
    â bool   â str â
    ââââââââââŞââââââĄ
    â true   â aaa â
    â false  â bbb â
    â null   â ccc â
    ââââââââââ´ââââââ

    Select all columns *except* for those with alphabetic names:

    >>> df.select(~cs.alpha())
    shape: (3, 2)
    âââââââŹâââââââââ
    â no1 â t or f â
    â --- â ---    â
    â i64 â bool   â
    âââââââŞâââââââââĄ
    â 100 â true   â
    â 200 â false  â
    â 300 â null   â
    âââââââ´âââââââââ

    >>> df.select(~cs.alpha(ignore_spaces=True))
    shape: (3, 1)
    âââââââ
    â no1 â
    â --- â
    â i64 â
    âââââââĄ
    â 100 â
    â 200 â
    â 300 â
    âââââââ
    úa-zA-Zú\p{Alphabetic}rľ   Ú ú^[ú]+$r0   ŠÚ
ascii_onlyr  Šr   r˘   ŠrN   r
  Úcol)r  r  Úre_alphaÚre_spaces       rT   r0   r0   G  sI    ńL 'yĐ,=HŮ#s¨HÜÜ	8*XJ cĐ*Ó+ŘŘ",¸}ŃMôđ rU   c          	     ó~    | rdnd}| rdnd}|rdnd}t        t        j                  d| | | dŤ      d	| |d
ŹŤ      S )uF  
    Select all columns with alphanumeric names (eg: only letters and the digits 0-9).

    Parameters
    ----------
    ascii_only
        Indicate whether to consider only ASCII alphabetic characters, or the full
        Unicode range of valid letters (accented, idiographic, etc).
    ignore_spaces
        Indicate whether to ignore the presence of spaces in column names; if so,
        only the other (non-space) characters are considered.

    Notes
    -----
    Matching column names cannot contain *any* non-alphabetic or integer characters.
    Note that the definition of "alphabetic" consists of all valid Unicode alphabetic
    characters (`\p{Alphabetic}`) and digit characters (`\d`) by default; this
    can be changed by setting `ascii_only=True`.

    Examples
    --------
    >>> import polars as pl
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "1st_col": [100, 200, 300],
    ...         "flagged": [True, False, True],
    ...         "00prefix": ["01:aa", "02:bb", "03:cc"],
    ...         "last col": ["x", "y", "z"],
    ...     }
    ... )

    Select columns with alphanumeric names:

    >>> df.select(cs.alphanumeric())
    shape: (3, 2)
    âââââââââââŹâââââââââââ
    â flagged â 00prefix â
    â ---     â ---      â
    â bool    â str      â
    âââââââââââŞâââââââââââĄ
    â true    â 01:aa    â
    â false   â 02:bb    â
    â true    â 03:cc    â
    âââââââââââ´âââââââââââ

    >>> df.select(cs.alphanumeric(ignore_spaces=True))
    shape: (3, 3)
    âââââââââââŹâââââââââââŹâââââââââââ
    â flagged â 00prefix â last col â
    â ---     â ---      â ---      â
    â bool    â str      â str      â
    âââââââââââŞâââââââââââŞâââââââââââĄ
    â true    â 01:aa    â x        â
    â false   â 02:bb    â y        â
    â true    â 03:cc    â z        â
    âââââââââââ´âââââââââââ´âââââââââââ

    Select all columns *except* for those with alphanumeric names:

    >>> df.select(~cs.alphanumeric())
    shape: (3, 2)
    âââââââââââŹâââââââââââ
    â 1st_col â last col â
    â ---     â ---      â
    â i64     â str      â
    âââââââââââŞâââââââââââĄ
    â 100     â x        â
    â 200     â y        â
    â 300     â z        â
    âââââââââââ´âââââââââââ

    >>> df.select(~cs.alphanumeric(ignore_spaces=True))
    shape: (3, 1)
    âââââââââââ
    â 1st_col â
    â ---     â
    â i64     â
    âââââââââââĄ
    â 100     â
    â 200     â
    â 300     â
    âââââââââââ
    r  r  z0-9ú\drľ   r  r  r  r1   r  r  r  )r  r  r  Úre_digitr  s        rT   r1   r1   ś  sV    ńt 'yĐ,=HŮ"u¨HŮ#s¨HÜÜ	8*XJ x j°Đ4Ó5ŘŘ",¸}ŃMôđ rU   c                 óJ    t        t        j                  t        Ť      dŹŤ      S )uś  
    Select all binary columns.

    See Also
    --------
    by_dtype : Select all columns matching the given dtype(s).
    string : Select all string columns (optionally including categoricals).

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame({"a": [b"hello"], "b": ["world"], "c": [b"!"], "d": [":)"]})
    >>> df
    shape: (1, 4)
    ââââââââââââŹââââââââŹâââââââââŹââââââ
    â a        â b     â c      â d   â
    â ---      â ---   â ---    â --- â
    â binary   â str   â binary â str â
    ââââââââââââŞââââââââŞâââââââââŞââââââĄ
    â b"hello" â world â b"!"   â :)  â
    ââââââââââââ´ââââââââ´âââââââââ´ââââââ

    Select binary columns and export as a dict:

    >>> df.select(cs.binary()).to_dict(as_series=False)
    {'a': [b'hello'], 'c': [b'!']}

    Select all columns *except* for those that are binary:

    >>> df.select(~cs.binary()).to_dict(as_series=False)
    {'b': ['world'], 'd': [':)']}
    r2   r	  )rN   r
  r  r   rQ   rU   rT   r2   r2     s    ôB AEE¤&M°Ô9Đ9rU   c                 óJ    t        t        j                  t        Ť      dŹŤ      S )u)  
    Select all boolean columns.

    See Also
    --------
    by_dtype : Select all columns matching the given dtype(s).

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame({"n": range(1, 5)}).with_columns(n_even=pl.col("n") % 2 == 0)
    >>> df
    shape: (4, 2)
    âââââââŹâââââââââ
    â n   â n_even â
    â --- â ---    â
    â i64 â bool   â
    âââââââŞâââââââââĄ
    â 1   â false  â
    â 2   â true   â
    â 3   â false  â
    â 4   â true   â
    âââââââ´âââââââââ

    Select and invert boolean columns:

    >>> df.with_columns(is_odd=cs.boolean().not_())
    shape: (4, 3)
    âââââââŹâââââââââŹâââââââââ
    â n   â n_even â is_odd â
    â --- â ---    â ---    â
    â i64 â bool   â bool   â
    âââââââŞâââââââââŞâââââââââĄ
    â 1   â false  â true   â
    â 2   â true   â false  â
    â 3   â false  â true   â
    â 4   â true   â false  â
    âââââââ´âââââââââ´âââââââââ

    Select all columns *except* for those that are boolean:

    >>> df.select(~cs.boolean())
    shape: (4, 1)
    âââââââ
    â n   â
    â --- â
    â i64 â
    âââââââĄ
    â 1   â
    â 2   â
    â 3   â
    â 4   â
    âââââââ
    r3   r	  )rN   r
  r  r   rQ   rU   rT   r3   r3   >  s    ôn AEE¤'N°Ô;Đ;rU   c                 óz   g }| D ]  }t        |Ť      st        |t        Ť      r|j                  |Ť       0t        |t        Ť      rD|D ]>  }t        |Ť      s t        |t        Ť      sd|}t        |Ť      |j                  |Ť       @ d|}t        |Ť       t        t        j                  |Ť      dd|iŹŤ      S )u´  
    Select all columns matching the given dtypes.

    See Also
    --------
    by_name : Select all columns matching the given names.
    by_index : Select all columns matching the given indices.

    Examples
    --------
    >>> from datetime import date
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "dt": [date(1999, 12, 31), date(2024, 1, 1), date(2010, 7, 5)],
    ...         "value": [1_234_500, 5_000_555, -4_500_000],
    ...         "other": ["foo", "bar", "foo"],
    ...     }
    ... )

    Select all columns with date or string dtypes:

    >>> df.select(cs.by_dtype(pl.Date, pl.String))
    shape: (3, 2)
    ââââââââââââââŹââââââââ
    â dt         â other â
    â ---        â ---   â
    â date       â str   â
    ââââââââââââââŞââââââââĄ
    â 1999-12-31 â foo   â
    â 2024-01-01 â bar   â
    â 2010-07-05 â foo   â
    ââââââââââââââ´ââââââââ

    Select all columns that are not of date or string dtype:

    >>> df.select(~cs.by_dtype(pl.Date, pl.String))
    shape: (3, 1)
    ââââââââââââ
    â value    â
    â ---      â
    â i64      â
    ââââââââââââĄ
    â 1234500  â
    â 5000555  â
    â -4500000 â
    ââââââââââââ

    Group by string columns and sum the numeric columns:

    >>> df.group_by(cs.string()).agg(cs.numeric().sum()).sort(by="other")
    shape: (2, 2)
    âââââââââŹâââââââââââ
    â other â value    â
    â ---   â ---      â
    â str   â i64      â
    âââââââââŞâââââââââââĄ
    â bar   â 5000555  â
    â foo   â -3265500 â
    âââââââââ´âââââââââââ
    zinvalid dtype: r4   r   r  )	r   rY   Útyperl   r   rc   rN   r
  r  )r   Ú
all_dtypesÚtpÚtri   s        rT   r4   r4   x  sÂ    đJ 9;JŘň !Ü2Ô¤*¨R´Ô"6Ř×ŃbŐ!ÜJÔ'Řň %Ü'¨Ô*Źj¸źDÔ.AŘ+¨A¨5Đ1CÜ# C.Đ(Ř×!Ń! !Ő$ń	%đ $ B 6Đ*CÜC.Đ đ!ô Ü	jÓ 
¸Ŕ*Đ7Môđ rU   c                 ó   g }| D ][  }t        |t        t        fŤ      r|j                  |Ť       +t        |t        Ť      r|j                  |Ť       Md|}t        |Ť       t        t        j                  | dd| iŹŤ      S )u  
    Select all columns matching the given indices (or range objects).

    Parameters
    ----------
    *indices
        One or more column indices (or range objects).
        Negative indexing is supported.

    Notes
    -----
    Matching columns are returned in the order in which their indexes
    appear in the selector, not the underlying schema order.

    See Also
    --------
    by_dtype : Select all columns matching the given dtypes.
    by_name : Select all columns matching the given names.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "key": ["abc"],
    ...         **{f"c{i:02}": [0.5 * i] for i in range(100)},
    ...     },
    ... )
    >>> print(df)
    shape: (1, 101)
    âââââââŹââââââŹââââââŹââââââŹââââŹâââââââŹâââââââŹâââââââŹâââââââ
    â key â c00 â c01 â c02 â âŚ â c96  â c97  â c98  â c99  â
    â --- â --- â --- â --- â   â ---  â ---  â ---  â ---  â
    â str â f64 â f64 â f64 â   â f64  â f64  â f64  â f64  â
    âââââââŞââââââŞââââââŞââââââŞââââŞâââââââŞâââââââŞâââââââŞâââââââĄ
    â abc â 0.0 â 0.5 â 1.0 â âŚ â 48.0 â 48.5 â 49.0 â 49.5 â
    âââââââ´ââââââ´ââââââ´ââââââ´ââââ´âââââââ´âââââââ´âââââââ´âââââââ

    Select columns by index ("key" column and the two first/last columns):

    >>> df.select(cs.by_index(0, 1, 2, -2, -1))
    shape: (1, 5)
    âââââââŹââââââŹââââââŹâââââââŹâââââââ
    â key â c00 â c01 â c98  â c99  â
    â --- â --- â --- â ---  â ---  â
    â str â f64 â f64 â f64  â f64  â
    âââââââŞââââââŞââââââŞâââââââŞâââââââĄ
    â abc â 0.0 â 0.5 â 49.0 â 49.5 â
    âââââââ´ââââââ´ââââââ´âââââââ´âââââââ

    Select the "key" column and use a `range` object to select various columns.
    Note that you can freely mix and match integer indices and `range` objects:

    >>> df.select(cs.by_index(0, range(1, 101, 20)))
    shape: (1, 6)
    âââââââŹââââââŹâââââââŹâââââââŹâââââââŹâââââââ
    â key â c00 â c20  â c40  â c60  â c80  â
    â --- â --- â ---  â ---  â ---  â ---  â
    â str â f64 â f64  â f64  â f64  â f64  â
    âââââââŞââââââŞâââââââŞâââââââŞâââââââŞâââââââĄ
    â abc â 0.0 â 10.0 â 20.0 â 30.0 â 40.0 â
    âââââââ´ââââââ´âââââââ´âââââââ´âââââââ´âââââââ

    >>> df.select(cs.by_index(0, range(101, 0, -25)))
    shape: (1, 5)
    âââââââŹâââââââŹâââââââŹâââââââŹââââââ
    â key â c75  â c50  â c25  â c00 â
    â --- â ---  â ---  â ---  â --- â
    â str â f64  â f64  â f64  â f64 â
    âââââââŞâââââââŞâââââââŞâââââââŞââââââĄ
    â abc â 37.5 â 25.0 â 12.5 â 0.0 â
    âââââââ´âââââââ´âââââââ´âââââââ´ââââââ

    Select all columns *except* for the even-indexed ones:

    >>> df.select(~cs.by_index(range(1, 100, 2)))
    shape: (1, 51)
    âââââââŹââââââŹââââââŹââââââŹââââŹâââââââŹâââââââŹâââââââŹâââââââ
    â key â c01 â c03 â c05 â âŚ â c93  â c95  â c97  â c99  â
    â --- â --- â --- â --- â   â ---  â ---  â ---  â ---  â
    â str â f64 â f64 â f64 â   â f64  â f64  â f64  â f64  â
    âââââââŞââââââŞââââââŞââââââŞââââŞâââââââŞâââââââŞâââââââŞâââââââĄ
    â abc â 0.5 â 1.5 â 2.5 â âŚ â 46.5 â 47.5 â 48.5 â 49.5 â
    âââââââ´ââââââ´ââââââ´ââââââ´ââââ´âââââââ´âââââââ´âââââââ´âââââââ
    zinvalid index value: r5   z*indicesr  )
rY   Úranger   rk   rů   rl   rc   rN   r
  Únth)ÚindicesÚall_indicesÚidxri   s       rT   r5   r5   Đ  s    đl  KŘň !ÜcE¤8Đ,Ô-Ř×ŃsŐ#ÜSÔ!Ř×ŃsŐ#ŕ)¨#¨Đ1CÜC.Đ đ!ô Ü	{Đ *¸*ŔgĐ9Nôđ rU   )Úrequire_allc                ó   g }|D ]|  }t        |t        Ť      r|j                  |Ť       %t        |t        Ť      r9|D ]3  }t        |t        Ť      sd|}t	        |Ť      |j                  |Ť       5 nd|}t	        |Ť       d|i}|}| s!ddj                  d |D Ť       Ť       d}| |d<   t        t        j                  |Ť      d|Ź	Ť      S )
uá  
    Select all columns matching the given names.

    .. versionadded:: 0.20.27
      The `require_all` parameter was added.

    Parameters
    ----------
    *names
        One or more names of columns to select.
    require_all
        Whether to match *all* names (the default) or *any* of the names.

    Notes
    -----
    Matching columns are returned in the order in which they are declared in
    the selector, not the underlying schema order.

    See Also
    --------
    by_dtype : Select all columns matching the given dtypes.
    by_index : Select all columns matching the given indices.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": ["x", "y"],
    ...         "bar": [123, 456],
    ...         "baz": [2.0, 5.5],
    ...         "zap": [False, True],
    ...     }
    ... )

    Select columns by name:

    >>> df.select(cs.by_name("foo", "bar"))
    shape: (2, 2)
    âââââââŹââââââ
    â foo â bar â
    â --- â --- â
    â str â i64 â
    âââââââŞââââââĄ
    â x   â 123 â
    â y   â 456 â
    âââââââ´ââââââ

    Match *any* of the given columns by name:

    >>> df.select(cs.by_name("baz", "moose", "foo", "bear", require_all=False))
    shape: (2, 2)
    âââââââŹââââââ
    â foo â baz â
    â --- â --- â
    â str â f64 â
    âââââââŞââââââĄ
    â x   â 2.0 â
    â y   â 5.5 â
    âââââââ´ââââââ

    Match all columns *except* for those given:

    >>> df.select(~cs.by_name("foo", "bar"))
    shape: (2, 2)
    âââââââŹââââââââ
    â baz â zap   â
    â --- â ---   â
    â f64 â bool  â
    âââââââŞââââââââĄ
    â 2.0 â false â
    â 5.5 â true  â
    âââââââ´ââââââââ
    zinvalid name: z*namesz^(r   c              3  ó2   K   | ]  }t        |Ť        y ­wrP   r  )r   Únms     rT   r   zby_name.<locals>.<genexpr>  s   č ř Ň"E°R¤9¨R§=Ń"Eůr¸   z)$r)  r6   r  )	rY   r   rl   r   rc   r   rN   r
  r  )r)  r   Ú	all_namesr,  Únri   Úselector_paramsÚ
match_colss           rT   r6   r6   5  së    đV IŘň !Üb#ÔŘ×ŃRŐ ÜJÔ'Řň $Ü! !¤SÔ)Ř*¨1¨%Đ0CÜ# C.Đ(Ř× Ń  Ő#ń	$đ # 2 &Đ)CÜC.Đ đ!đ (0°Đ&;OŘ"+JŮŘ#((Ń"E¸9Ô"EÓEĐFŔbĐI
Ř)4Ń&äÜ	jÓŘŘ"ôđ rU   c                 óJ    t        t        j                  t        Ť      dŹŤ      S )ub  
    Select all categorical columns.

    See Also
    --------
    by_dtype : Select all columns matching the given dtype(s).
    string : Select all string columns (optionally including categoricals).

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": ["xx", "yy"],
    ...         "bar": [123, 456],
    ...         "baz": [2.0, 5.5],
    ...     },
    ...     schema_overrides={"foo": pl.Categorical},
    ... )

    Select all categorical columns:

    >>> df.select(cs.categorical())
    shape: (2, 1)
    âââââââ
    â foo â
    â --- â
    â cat â
    âââââââĄ
    â xx  â
    â yy  â
    âââââââ

    Select all columns *except* for those that are categorical:

    >>> df.select(~cs.categorical())
    shape: (2, 2)
    âââââââŹââââââ
    â bar â baz â
    â --- â --- â
    â i64 â f64 â
    âââââââŞââââââĄ
    â 123 â 2.0 â
    â 456 â 5.5 â
    âââââââ´ââââââ
    r7   r	  )rN   r
  r  r   rQ   rU   rT   r7   r7     s    ô^ AEE¤+Ó.°]ÔCĐCrU   c                 ój    t        | Ť      }d| d}t        t        j                  |Ť      dd|iŹŤ      S )u¸  
    Select columns whose names contain the given literal substring(s).

    Parameters
    ----------
    substring
        Substring(s) that matching column names should contain.

    See Also
    --------
    matches : Select all columns that match the given regex pattern.
    ends_with : Select columns that end with the given substring(s).
    starts_with : Select columns that start with the given substring(s).

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": ["x", "y"],
    ...         "bar": [123, 456],
    ...         "baz": [2.0, 5.5],
    ...         "zap": [False, True],
    ...     }
    ... )

    Select columns that contain the substring 'ba':

    >>> df.select(cs.contains("ba"))
    shape: (2, 2)
    âââââââŹââââââ
    â bar â baz â
    â --- â --- â
    â i64 â f64 â
    âââââââŞââââââĄ
    â 123 â 2.0 â
    â 456 â 5.5 â
    âââââââ´ââââââ

    Select columns that contain the substring 'ba' or the letter 'z':

    >>> df.select(cs.contains("ba", "z"))
    shape: (2, 3)
    âââââââŹââââââŹââââââââ
    â bar â baz â zap   â
    â --- â --- â ---   â
    â i64 â f64 â bool  â
    âââââââŞââââââŞââââââââĄ
    â 123 â 2.0 â false â
    â 456 â 5.5 â true  â
    âââââââ´ââââââ´ââââââââ

    Select all columns *except* for those that contain the substring 'ba':

    >>> df.select(~cs.contains("ba"))
    shape: (2, 2)
    âââââââŹââââââââ
    â foo â zap   â
    â --- â ---   â
    â str â bool  â
    âââââââŞââââââââĄ
    â x   â false â
    â y   â true  â
    âââââââ´ââââââââ
    ú^.*ú.*$r8   z
*substringr  Šr  rN   r
  r  )Ú	substringÚescaped_substringÚ
raw_paramss      rT   r8   r8   Í  sE    ôD # 9Ó-ĐŘĐ(Đ)¨Đ-JäÜ	jÓŘŘ Đ"3Đ4ôđ rU   c                 óJ    t        t        j                  t        Ť      dŹŤ      S )u  
    Select all date columns.

    See Also
    --------
    datetime : Select all datetime columns, optionally filtering by time unit/zone.
    duration : Select all duration columns, optionally filtering by time unit.
    temporal : Select all temporal columns.
    time : Select all time columns.

    Examples
    --------
    >>> from datetime import date, datetime, time
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "dtm": [datetime(2001, 5, 7, 10, 25), datetime(2031, 12, 31, 0, 30)],
    ...         "dt": [date(1999, 12, 31), date(2024, 8, 9)],
    ...         "tm": [time(0, 0, 0), time(23, 59, 59)],
    ...     },
    ... )

    Select all date columns:

    >>> df.select(cs.date())
    shape: (2, 1)
    ââââââââââââââ
    â dt         â
    â ---        â
    â date       â
    ââââââââââââââĄ
    â 1999-12-31 â
    â 2024-08-09 â
    ââââââââââââââ

    Select all columns *except* for those that are dates:

    >>> df.select(~cs.date())
    shape: (2, 2)
    âââââââââââââââââââââââŹâââââââââââ
    â dtm                 â tm       â
    â ---                 â ---      â
    â datetime[Îźs]        â time     â
    âââââââââââââââââââââââŞâââââââââââĄ
    â 2001-05-07 10:25:00 â 00:00:00 â
    â 2031-12-31 00:30:00 â 23:59:59 â
    âââââââââââââââââââââââ´âââââââââââ
    r9   r	  )rN   r
  r  r   rQ   rU   rT   r9   r9     ó    ôb AEE¤$K¨fÔ5Đ5rU   c           	     ó<   | g d˘} nt        | t        Ť      r| gn
t        | Ť      } |dg}n&|r$t        |t        t        fŤ      r|gn
t        |Ť      }| D cg c]  }|D ]  }t	        ||Ť        }}}t        t        j                  |Ť      d| |dŹŤ      S c c}}w )uO  
    Select all datetime columns, optionally filtering by time unit/zone.

    Parameters
    ----------
    time_unit
        One (or more) of the allowed timeunit precision strings, "ms", "us", and "ns".
        Omit to select columns with any valid timeunit.
    time_zone
        * One or more timezone strings, as defined in zoneinfo (to see valid options
          run `import zoneinfo; zoneinfo.available_timezones()` for a full list).
        * Set `None` to select Datetime columns that do not have a timezone.
        * Set "*" to select Datetime columns that have *any* timezone.

    See Also
    --------
    date : Select all date columns.
    duration : Select all duration columns, optionally filtering by time unit.
    temporal : Select all temporal columns.
    time : Select all time columns.

    Examples
    --------
    >>> from datetime import datetime, date, timezone
    >>> import polars.selectors as cs
    >>> from zoneinfo import ZoneInfo
    >>> tokyo_tz = ZoneInfo("Asia/Tokyo")
    >>> utc_tz = timezone.utc
    >>> df = pl.DataFrame(
    ...     {
    ...         "tstamp_tokyo": [
    ...             datetime(1999, 7, 21, 5, 20, 16, 987654, tzinfo=tokyo_tz),
    ...             datetime(2000, 5, 16, 6, 21, 21, 123465, tzinfo=tokyo_tz),
    ...         ],
    ...         "tstamp_utc": [
    ...             datetime(2023, 4, 10, 12, 14, 16, 999000, tzinfo=utc_tz),
    ...             datetime(2025, 8, 25, 14, 18, 22, 666000, tzinfo=utc_tz),
    ...         ],
    ...         "tstamp": [
    ...             datetime(2000, 11, 20, 18, 12, 16, 600000),
    ...             datetime(2020, 10, 30, 10, 20, 25, 123000),
    ...         ],
    ...         "dt": [date(1999, 12, 31), date(2010, 7, 5)],
    ...     },
    ...     schema_overrides={
    ...         "tstamp_tokyo": pl.Datetime("ns", "Asia/Tokyo"),
    ...         "tstamp_utc": pl.Datetime("us", "UTC"),
    ...     },
    ... )

    Select all datetime columns:

    >>> df.select(cs.datetime())
    shape: (2, 3)
    ââââââââââââââââââââââââââââââââââŹââââââââââââââââââââââââââââââŹââââââââââââââââââââââââââ
    â tstamp_tokyo                   â tstamp_utc                  â tstamp                  â
    â ---                            â ---                         â ---                     â
    â datetime[ns, Asia/Tokyo]       â datetime[Îźs, UTC]           â datetime[Îźs]            â
    ââââââââââââââââââââââââââââââââââŞââââââââââââââââââââââââââââââŞââââââââââââââââââââââââââĄ
    â 1999-07-21 05:20:16.987654 JST â 2023-04-10 12:14:16.999 UTC â 2000-11-20 18:12:16.600 â
    â 2000-05-16 06:21:21.123465 JST â 2025-08-25 14:18:22.666 UTC â 2020-10-30 10:20:25.123 â
    ââââââââââââââââââââââââââââââââââ´ââââââââââââââââââââââââââââââ´ââââââââââââââââââââââââââ

    Select all datetime columns that have 'us' precision:

    >>> df.select(cs.datetime("us"))
    shape: (2, 2)
    âââââââââââââââââââââââââââââââŹââââââââââââââââââââââââââ
    â tstamp_utc                  â tstamp                  â
    â ---                         â ---                     â
    â datetime[Îźs, UTC]           â datetime[Îźs]            â
    âââââââââââââââââââââââââââââââŞââââââââââââââââââââââââââĄ
    â 2023-04-10 12:14:16.999 UTC â 2000-11-20 18:12:16.600 â
    â 2025-08-25 14:18:22.666 UTC â 2020-10-30 10:20:25.123 â
    âââââââââââââââââââââââââââââââ´ââââââââââââââââââââââââââ

    Select all datetime columns that have *any* timezone:

    >>> df.select(cs.datetime(time_zone="*"))
    shape: (2, 2)
    ââââââââââââââââââââââââââââââââââŹââââââââââââââââââââââââââââââ
    â tstamp_tokyo                   â tstamp_utc                  â
    â ---                            â ---                         â
    â datetime[ns, Asia/Tokyo]       â datetime[Îźs, UTC]           â
    ââââââââââââââââââââââââââââââââââŞââââââââââââââââââââââââââââââĄ
    â 1999-07-21 05:20:16.987654 JST â 2023-04-10 12:14:16.999 UTC â
    â 2000-05-16 06:21:21.123465 JST â 2025-08-25 14:18:22.666 UTC â
    ââââââââââââââââââââââââââââââââââ´ââââââââââââââââââââââââââââââ

    Select all datetime columns that have a *specific* timezone:

    >>> df.select(cs.datetime(time_zone="UTC"))
    shape: (2, 1)
    âââââââââââââââââââââââââââââââ
    â tstamp_utc                  â
    â ---                         â
    â datetime[Îźs, UTC]           â
    âââââââââââââââââââââââââââââââĄ
    â 2023-04-10 12:14:16.999 UTC â
    â 2025-08-25 14:18:22.666 UTC â
    âââââââââââââââââââââââââââââââ

    Select all datetime columns that have NO timezone:

    >>> df.select(cs.datetime(time_zone=None))
    shape: (2, 1)
    âââââââââââââââââââââââââââ
    â tstamp                  â
    â ---                     â
    â datetime[Îźs]            â
    âââââââââââââââââââââââââââĄ
    â 2000-11-20 18:12:16.600 â
    â 2020-10-30 10:20:25.123 â
    âââââââââââââââââââââââââââ

    Select all columns *except* for datetime columns:

    >>> df.select(~cs.datetime())
    shape: (2, 1)
    ââââââââââââââ
    â dt         â
    â ---        â
    â date       â
    ââââââââââââââĄ
    â 1999-12-31 â
    â 2010-07-05 â
    ââââââââââââââ
    NŠÚmsÚusÚnsr:   )Ú	time_unitÚ	time_zoner  )rY   r   Úlistr   r   rN   r
  r  )r@  rA  ÚtuÚtzÚdatetime_dtypess        rT   r:   r:   M  sŚ    đN ĐÚ&	ä#-¨iźÔ#=YKÄ4Č	Ă?	ŕĐŘF	Ů	ä% i´#´x°ÔAYKÄtČIĂđ 	đ 3<×P¨BŔiŇPŔx  BŐ'ĐPĐ'ĐPOŃPäÜ	oÓŘŘ!*¸ŃCôđ ůó Qs   ÁBc                 óJ    t        t        j                  t        Ť      dŹŤ      S )u  
    Select all decimal columns.

    See Also
    --------
    float : Select all float columns.
    integer : Select all integer columns.
    numeric : Select all numeric columns.

    Examples
    --------
    >>> from decimal import Decimal as D
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": ["x", "y"],
    ...         "bar": [D(123), D(456)],
    ...         "baz": [D("2.0005"), D("-50.5555")],
    ...     },
    ...     schema_overrides={"baz": pl.Decimal(scale=5, precision=10)},
    ... )

    Select all decimal columns:

    >>> df.select(cs.decimal())
    shape: (2, 2)
    ââââââââââââââââŹââââââââââââââââ
    â bar          â baz           â
    â ---          â ---           â
    â decimal[*,0] â decimal[10,5] â
    ââââââââââââââââŞââââââââââââââââĄ
    â 123          â 2.00050       â
    â 456          â -50.55550     â
    ââââââââââââââââ´ââââââââââââââââ

    Select all columns *except* the decimal ones:

    >>> df.select(~cs.decimal())
    shape: (2, 1)
    âââââââ
    â foo â
    â --- â
    â str â
    âââââââĄ
    â x   â
    â y   â
    âââââââ
    r;   r	  )rN   r
  r  r   rQ   rU   rT   r;   r;   é  s    ôd AEE¤'N°Ô;Đ;rU   c                óV    | rdnd}t        t        j                  d| dŤ      dŹŤ      S )u
  
    Select all columns having names consisting only of digits.

    Notes
    -----
    Matching column names cannot contain *any* non-digit characters. Note that the
    definition of "digit" consists of all valid Unicode digit characters (`\d`)
    by default; this can be changed by setting `ascii_only=True`.

    Examples
    --------
    >>> import polars as pl
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "key": ["aaa", "bbb", "aaa", "bbb", "bbb"],
    ...         "year": [2001, 2001, 2025, 2025, 2001],
    ...         "value": [-25, 100, 75, -15, -5],
    ...     }
    ... ).pivot(
    ...     values="value",
    ...     index="key",
    ...     on="year",
    ...     aggregate_function="sum",
    ... )
    >>> print(df)
    shape: (2, 3)
    âââââââŹâââââââŹâââââââ
    â key â 2001 â 2025 â
    â --- â ---  â ---  â
    â str â i64  â i64  â
    âââââââŞâââââââŞâââââââĄ
    â aaa â -25  â 75   â
    â bbb â 95   â -15  â
    âââââââ´âââââââ´âââââââ

    Select columns with digit names:

    >>> df.select(cs.digit())
    shape: (2, 2)
    ââââââââŹâââââââ
    â 2001 â 2025 â
    â ---  â ---  â
    â i64  â i64  â
    ââââââââŞâââââââĄ
    â -25  â 75   â
    â 95   â -15  â
    ââââââââ´âââââââ

    Select all columns *except* for those with digit names:

    >>> df.select(~cs.digit())
    shape: (2, 1)
    âââââââ
    â key â
    â --- â
    â str â
    âââââââĄ
    â aaa â
    â bbb â
    âââââââ

    Demonstrate use of `ascii_only` flag (by default all valid unicode digits
    are considered, but this can be constrained to ascii 0-9):

    >>> df = pl.DataFrame({"ŕĽ§ŕĽŻŕĽŻŕĽŻ": [1999], "ŕĽ¨ŕĽŚŕĽ­ŕĽ­": [2077], "3000": [3000]})
    >>> df.select(cs.digit())
    shape: (1, 3)
    ââââââââŹâââââââŹâââââââ
    â ŕĽ§ŕĽŻŕĽŻŕĽŻ â ŕĽ¨ŕĽŚŕĽ­ŕĽ­ â 3000 â
    â ---  â ---  â ---  â
    â i64  â i64  â i64  â
    ââââââââŞâââââââŞâââââââĄ
    â 1999 â 2077 â 3000 â
    ââââââââ´âââââââ´âââââââ

    >>> df.select(cs.digit(ascii_only=True))
    shape: (1, 1)
    ââââââââ
    â 3000 â
    â ---  â
    â i64  â
    ââââââââĄ
    â 3000 â
    ââââââââ
    z[0-9]r  r   z+$r<   r	  r  )r  r  s     rT   r<   r<     s-    ńn &x¨5HÜAEE Q x j°Đ"3Ó4¸7ÔCĐCrU   c                óĚ    | g d˘} nt        | t        Ť      r| gn
t        | Ť      } | D cg c]  }t        |Ť       }}t	        t        j                  |Ť      dd| iŹŤ      S c c}w )ud  
    Select all duration columns, optionally filtering by time unit.

    Parameters
    ----------
    time_unit
        One (or more) of the allowed timeunit precision strings, "ms", "us", and "ns".
        Omit to select columns with any valid timeunit.

    See Also
    --------
    date : Select all date columns.
    datetime : Select all datetime columns, optionally filtering by time unit/zone.
    temporal : Select all temporal columns.
    time : Select all time columns.

    Examples
    --------
    >>> from datetime import date, timedelta
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "dt": [date(2022, 1, 31), date(2025, 7, 5)],
    ...         "td1": [
    ...             timedelta(days=1, milliseconds=123456),
    ...             timedelta(days=1, hours=23, microseconds=987000),
    ...         ],
    ...         "td2": [
    ...             timedelta(days=7, microseconds=456789),
    ...             timedelta(days=14, minutes=999, seconds=59),
    ...         ],
    ...         "td3": [
    ...             timedelta(weeks=4, days=-10, microseconds=999999),
    ...             timedelta(weeks=3, milliseconds=123456, microseconds=1),
    ...         ],
    ...     },
    ...     schema_overrides={
    ...         "td1": pl.Duration("ms"),
    ...         "td2": pl.Duration("us"),
    ...         "td3": pl.Duration("ns"),
    ...     },
    ... )

    Select all duration columns:

    >>> df.select(cs.duration())
    shape: (2, 3)
    ââââââââââââââââââŹââââââââââââââââââŹâââââââââââââââââââââ
    â td1            â td2             â td3                â
    â ---            â ---             â ---                â
    â duration[ms]   â duration[Îźs]    â duration[ns]       â
    ââââââââââââââââââŞââââââââââââââââââŞâââââââââââââââââââââĄ
    â 1d 2m 3s 456ms â 7d 456789Âľs     â 18d 999999Âľs       â
    â 1d 23h 987ms   â 14d 16h 39m 59s â 21d 2m 3s 456001Âľs â
    ââââââââââââââââââ´ââââââââââââââââââ´âââââââââââââââââââââ

    Select all duration columns that have 'ms' precision:

    >>> df.select(cs.duration("ms"))
    shape: (2, 1)
    ââââââââââââââââââ
    â td1            â
    â ---            â
    â duration[ms]   â
    ââââââââââââââââââĄ
    â 1d 2m 3s 456ms â
    â 1d 23h 987ms   â
    ââââââââââââââââââ

    Select all duration columns that have 'ms' OR 'ns' precision:

    >>> df.select(cs.duration(["ms", "ns"]))
    shape: (2, 2)
    ââââââââââââââââââŹâââââââââââââââââââââ
    â td1            â td3                â
    â ---            â ---                â
    â duration[ms]   â duration[ns]       â
    ââââââââââââââââââŞâââââââââââââââââââââĄ
    â 1d 2m 3s 456ms â 18d 999999Âľs       â
    â 1d 23h 987ms   â 21d 2m 3s 456001Âľs â
    ââââââââââââââââââ´âââââââââââââââââââââ

    Select all columns *except* for duration columns:

    >>> df.select(~cs.duration())
    shape: (2, 1)
    ââââââââââââââ
    â dt         â
    â ---        â
    â date       â
    ââââââââââââââĄ
    â 2022-01-31 â
    â 2025-07-05 â
    ââââââââââââââ
    r<  r=   r@  r  )rY   r   rB  r   rN   r
  r  )r@  rC  Úduration_dtypess      rT   r=   r=   y  sf    đD ĐÚ&	ä#-¨iźÔ#=YKÄ4Č	Ă?	ŕ.7Ö8¨x |Đ8OĐ8ÜÜ	oÓŘŘ Đ+ôđ ůň 9s   ŞA!c                 ój    t        | Ť      }d| d}t        t        j                  |Ť      dd|iŹŤ      S )u/  
    Select columns that end with the given substring(s).

    See Also
    --------
    contains : Select columns that contain the given literal substring(s).
    matches : Select all columns that match the given regex pattern.
    starts_with : Select columns that start with the given substring(s).

    Parameters
    ----------
    suffix
        Substring(s) that matching column names should end with.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": ["x", "y"],
    ...         "bar": [123, 456],
    ...         "baz": [2.0, 5.5],
    ...         "zap": [False, True],
    ...     }
    ... )

    Select columns that end with the substring 'z':

    >>> df.select(cs.ends_with("z"))
    shape: (2, 1)
    âââââââ
    â baz â
    â --- â
    â f64 â
    âââââââĄ
    â 2.0 â
    â 5.5 â
    âââââââ

    Select columns that end with *either* the letter 'z' or 'r':

    >>> df.select(cs.ends_with("z", "r"))
    shape: (2, 2)
    âââââââŹââââââ
    â bar â baz â
    â --- â --- â
    â i64 â f64 â
    âââââââŞââââââĄ
    â 123 â 2.0 â
    â 456 â 5.5 â
    âââââââ´ââââââ

    Select all columns *except* for those that end with the substring 'z':

    >>> df.select(~cs.ends_with("z"))
    shape: (2, 3)
    âââââââŹââââââŹââââââââ
    â foo â bar â zap   â
    â --- â --- â ---   â
    â str â i64 â bool  â
    âââââââŞââââââŞââââââââĄ
    â x   â 123 â false â
    â y   â 456 â true  â
    âââââââ´ââââââ´ââââââââ
    r3  r   r>   z*suffixr  r5  )ÚsuffixÚescaped_suffixr8  s      rT   r>   r>   č  sB    ôD   Ó'NŘ~Đ& aĐ(JäÜ	jÓŘŘ~Đ.ôđ rU   c                ó    t        | g|˘­  S )u  
    Select all columns except those matching the given columns, datatypes, or selectors.

    Parameters
    ----------
    columns
        One or more columns (col or name), datatypes, columns, or selectors representing
        the columns to exclude.
    *more_columns
        Additional columns, datatypes, or selectors to exclude, specified as positional
        arguments.

    Notes
    -----
    If excluding a single selector it is simpler to write as `~selector` instead.

    Examples
    --------
    Exclude by column name(s):

    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "aa": [1, 2, 3],
    ...         "ba": ["a", "b", None],
    ...         "cc": [None, 2.5, 1.5],
    ...     }
    ... )
    >>> df.select(cs.exclude("ba", "xx"))
    shape: (3, 2)
    âââââââŹâââââââ
    â aa  â cc   â
    â --- â ---  â
    â i64 â f64  â
    âââââââŞâââââââĄ
    â 1   â null â
    â 2   â 2.5  â
    â 3   â 1.5  â
    âââââââ´âââââââ

    Exclude using a column name, a selector, and a dtype:

    >>> df.select(cs.exclude("aa", cs.string(), pl.UInt32))
    shape: (3, 1)
    ââââââââ
    â cc   â
    â ---  â
    â f64  â
    ââââââââĄ
    â null â
    â 2.5  â
    â 1.5  â
    ââââââââ
    )r   )ÚcolumnsÚmore_columnss     rT   r?   r?   4  s    ô@ ! Đ8¨<Ň8Đ8Đ8rU   c                 ó@    t        t        j                  Ť       dŹŤ      S )ub  
    Select the first column in the current scope.

    See Also
    --------
    all : Select all columns.
    last : Select the last column in the current scope.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": ["x", "y"],
    ...         "bar": [123, 456],
    ...         "baz": [2.0, 5.5],
    ...         "zap": [0, 1],
    ...     }
    ... )

    Select the first column:

    >>> df.select(cs.first())
    shape: (2, 1)
    âââââââ
    â foo â
    â --- â
    â str â
    âââââââĄ
    â x   â
    â y   â
    âââââââ

    Select everything  *except* for the first column:

    >>> df.select(~cs.first())
    shape: (2, 3)
    âââââââŹââââââŹââââââ
    â bar â baz â zap â
    â --- â --- â --- â
    â i64 â f64 â i64 â
    âââââââŞââââââŞââââââĄ
    â 123 â 2.0 â 0   â
    â 456 â 5.5 â 1   â
    âââââââ´ââââââ´ââââââ
    rA   r	  )rN   r
  rA   rQ   rU   rT   rA   rA   w  s    ô^ AGGI¨GÔ4Đ4rU   c                 óJ    t        t        j                  t        Ť      dŹŤ      S )u  
    Select all float columns.

    See Also
    --------
    integer : Select all integer columns.
    numeric : Select all numeric columns.
    signed_integer : Select all signed integer columns.
    unsigned_integer : Select all unsigned integer columns.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": ["x", "y"],
    ...         "bar": [123, 456],
    ...         "baz": [2.0, 5.5],
    ...         "zap": [0.0, 1.0],
    ...     },
    ...     schema_overrides={"baz": pl.Float32, "zap": pl.Float64},
    ... )

    Select all float columns:

    >>> df.select(cs.float())
    shape: (2, 2)
    âââââââŹââââââ
    â baz â zap â
    â --- â --- â
    â f32 â f64 â
    âââââââŞââââââĄ
    â 2.0 â 0.0 â
    â 5.5 â 1.0 â
    âââââââ´ââââââ

    Select all columns *except* for those that are float:

    >>> df.select(~cs.float())
    shape: (2, 2)
    âââââââŹââââââ
    â foo â bar â
    â --- â --- â
    â str â i64 â
    âââââââŞââââââĄ
    â x   â 123 â
    â y   â 456 â
    âââââââ´ââââââ
    rB   r	  )rN   r
  r  r   rQ   rU   rT   rB   rB   Š  s    ôd AEE¤,Ó/°gÔ>Đ>rU   c                 óJ    t        t        j                  t        Ť      dŹŤ      S )uô  
    Select all integer columns.

    See Also
    --------
    by_dtype : Select columns by dtype.
    float : Select all float columns.
    numeric : Select all numeric columns.
    signed_integer : Select all signed integer columns.
    unsigned_integer : Select all unsigned integer columns.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": ["x", "y"],
    ...         "bar": [123, 456],
    ...         "baz": [2.0, 5.5],
    ...         "zap": [0, 1],
    ...     }
    ... )

    Select all integer columns:

    >>> df.select(cs.integer())
    shape: (2, 2)
    âââââââŹââââââ
    â bar â zap â
    â --- â --- â
    â i64 â i64 â
    âââââââŞââââââĄ
    â 123 â 0   â
    â 456 â 1   â
    âââââââ´ââââââ

    Select all columns *except* for those that are integer :

    >>> df.select(~cs.integer())
    shape: (2, 2)
    âââââââŹââââââ
    â foo â baz â
    â --- â --- â
    â str â f64 â
    âââââââŞââââââĄ
    â x   â 2.0 â
    â y   â 5.5 â
    âââââââ´ââââââ
    rC   r	  )rN   r
  r  r   rQ   rU   rT   rC   rC   Ţ  s    ôd AEE¤.Ó1¸	ÔBĐBrU   c                 óJ    t        t        j                  t        Ť      dŹŤ      S )u1  
    Select all signed integer columns.

    See Also
    --------
    by_dtype : Select columns by dtype.
    float : Select all float columns.
    integer : Select all integer columns.
    numeric : Select all numeric columns.
    unsigned_integer : Select all unsigned integer columns.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": [-123, -456],
    ...         "bar": [3456, 6789],
    ...         "baz": [7654, 4321],
    ...         "zap": ["ab", "cd"],
    ...     },
    ...     schema_overrides={"bar": pl.UInt32, "baz": pl.UInt64},
    ... )

    Select all signed integer columns:

    >>> df.select(cs.signed_integer())
    shape: (2, 1)
    ââââââââ
    â foo  â
    â ---  â
    â i64  â
    ââââââââĄ
    â -123 â
    â -456 â
    ââââââââ

    >>> df.select(~cs.signed_integer())
    shape: (2, 3)
    ââââââââŹâââââââŹââââââ
    â bar  â baz  â zap â
    â ---  â ---  â --- â
    â u32  â u64  â str â
    ââââââââŞâââââââŞââââââĄ
    â 3456 â 7654 â ab  â
    â 6789 â 4321 â cd  â
    ââââââââ´âââââââ´ââââââ

    Select all integer columns (both signed and unsigned):

    >>> df.select(cs.integer())
    shape: (2, 3)
    ââââââââŹâââââââŹâââââââ
    â foo  â bar  â baz  â
    â ---  â ---  â ---  â
    â i64  â u32  â u64  â
    ââââââââŞâââââââŞâââââââĄ
    â -123 â 3456 â 7654 â
    â -456 â 6789 â 4321 â
    ââââââââ´âââââââ´âââââââ
    rH   r	  )rN   r
  r  r!   rQ   rU   rT   rH   rH     s    ô| AEEÔ"7Ó8Đ?OÔPĐPrU   c                 óJ    t        t        j                  t        Ť      dŹŤ      S )u|  
    Select all unsigned integer columns.

    See Also
    --------
    by_dtype : Select columns by dtype.
    float : Select all float columns.
    integer : Select all integer columns.
    numeric : Select all numeric columns.
    signed_integer : Select all signed integer columns.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": [-123, -456],
    ...         "bar": [3456, 6789],
    ...         "baz": [7654, 4321],
    ...         "zap": ["ab", "cd"],
    ...     },
    ...     schema_overrides={"bar": pl.UInt32, "baz": pl.UInt64},
    ... )

    Select all unsigned integer columns:

    >>> df.select(cs.unsigned_integer())
    shape: (2, 2)
    ââââââââŹâââââââ
    â bar  â baz  â
    â ---  â ---  â
    â u32  â u64  â
    ââââââââŞâââââââĄ
    â 3456 â 7654 â
    â 6789 â 4321 â
    ââââââââ´âââââââ

    Select all columns *except* for those that are unsigned integers:

    >>> df.select(~cs.unsigned_integer())
    shape: (2, 2)
    ââââââââŹââââââ
    â foo  â zap â
    â ---  â --- â
    â i64  â str â
    ââââââââŞââââââĄ
    â -123 â ab  â
    â -456 â cd  â
    ââââââââ´ââââââ

    Select all integer columns (both signed and unsigned):

    >>> df.select(cs.integer())
    shape: (2, 3)
    ââââââââŹâââââââŹâââââââ
    â foo  â bar  â baz  â
    â ---  â ---  â ---  â
    â i64  â u32  â u64  â
    ââââââââŞâââââââŞâââââââĄ
    â -123 â 3456 â 7654 â
    â -456 â 6789 â 4321 â
    ââââââââ´âââââââ´âââââââ
    rM   r	  )rN   r
  r  r#   rQ   rU   rT   rM   rM   T  s    ô@ AEEÔ"9Ó:ĐASÔTĐTrU   c                 ó@    t        t        j                  Ť       dŹŤ      S )u_  
    Select the last column in the current scope.

    See Also
    --------
    all : Select all columns.
    first : Select the first column in the current scope.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": ["x", "y"],
    ...         "bar": [123, 456],
    ...         "baz": [2.0, 5.5],
    ...         "zap": [0, 1],
    ...     }
    ... )

    Select the last column:

    >>> df.select(cs.last())
    shape: (2, 1)
    âââââââ
    â zap â
    â --- â
    â i64 â
    âââââââĄ
    â 0   â
    â 1   â
    âââââââ

    Select everything  *except* for the last column:

    >>> df.select(~cs.last())
    shape: (2, 3)
    âââââââŹââââââŹââââââ
    â foo â bar â baz â
    â --- â --- â --- â
    â str â i64 â f64 â
    âââââââŞââââââŞââââââĄ
    â x   â 123 â 2.0 â
    â y   â 456 â 5.5 â
    âââââââ´ââââââ´ââââââ
    rE   r	  )rN   r
  rE   rQ   rU   rT   rE   rE     s    ô^ AFFH¨6Ô2Đ2rU   c                ó$   | dk(  r
t        Ť       S | j                  dŤ      r| dd } n| j                  dŤ      r| dd } | j                  dŤ      sdnd}| j                  dŤ      sd	nd}| |  | }t        t	        j
                  |Ť      d
d| iŹŤ      S )u÷  
    Select all columns that match the given regex pattern.

    See Also
    --------
    contains : Select all columns that contain the given substring.
    ends_with : Select all columns that end with the given substring(s).
    starts_with : Select all columns that start with the given substring(s).

    Parameters
    ----------
    pattern
        A valid regular expression pattern, compatible with the `regex crate
        <https://docs.rs/regex/latest/regex/>`_.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": ["x", "y"],
    ...         "bar": [123, 456],
    ...         "baz": [2.0, 5.5],
    ...         "zap": [0, 1],
    ...     }
    ... )

    Match column names containing an 'a', preceded by a character that is not 'z':

    >>> df.select(cs.matches("[^z]a"))
    shape: (2, 2)
    âââââââŹââââââ
    â bar â baz â
    â --- â --- â
    â i64 â f64 â
    âââââââŞââââââĄ
    â 123 â 2.0 â
    â 456 â 5.5 â
    âââââââ´ââââââ

    Do not match column names ending in 'R' or 'z' (case-insensitively):

    >>> df.select(~cs.matches(r"(?i)R|z$"))
    shape: (2, 2)
    âââââââŹââââââ
    â foo â zap â
    â --- â --- â
    â str â i64 â
    âââââââŞââââââĄ
    â x   â 0   â
    â y   â 1   â
    âââââââ´ââââââ
    z.*é   Néţ˙˙˙r   r3  r  r   r4  rF   Úpatternr  )r/   r   r   rN   r
  r  )rY  ÚpfxÚsfxr8  s       rT   rF   rF   É  sŁ    đl $Üuŕ×ŃdÔ#ŘabkGŘ×ŃdÔ#ŘcrlGŕ"×-Ń-¨cÔ2e¸Ř"×+Ń+¨CÔ0e°bŘuWI c UĐ+
äÜEE*ÓŘŘ! 7Đ+ô
đ 	
rU   c                 óJ    t        t        j                  t        Ť      dŹŤ      S )uF  
    Select all numeric columns.

    See Also
    --------
    by_dtype : Select columns by dtype.
    float : Select all float columns.
    integer : Select all integer columns.
    signed_integer : Select all signed integer columns.
    unsigned_integer : Select all unsigned integer columns.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": ["x", "y"],
    ...         "bar": [123, 456],
    ...         "baz": [2.0, 5.5],
    ...         "zap": [0, 0],
    ...     },
    ...     schema_overrides={"bar": pl.Int16, "baz": pl.Float32, "zap": pl.UInt8},
    ... )

    Match all numeric columns:

    >>> df.select(cs.numeric())
    shape: (2, 3)
    âââââââŹââââââŹââââââ
    â bar â baz â zap â
    â --- â --- â --- â
    â i16 â f32 â u8  â
    âââââââŞââââââŞââââââĄ
    â 123 â 2.0 â 0   â
    â 456 â 5.5 â 0   â
    âââââââ´ââââââ´ââââââ

    Match all columns *except* for those that are numeric:

    >>> df.select(~cs.numeric())
    shape: (2, 1)
    âââââââ
    â foo â
    â --- â
    â str â
    âââââââĄ
    â x   â
    â y   â
    âââââââ
    rG   r	  )rN   r
  r  r    rQ   rU   rT   rG   rG   	  s    ôf AEE¤.Ó1¸	ÔBĐBrU   c                 óJ    t        t        j                  t        Ť      dŹŤ      S )uŁ	  
    Select all object columns.

    See Also
    --------
    by_dtype : Select columns by dtype.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> from uuid import uuid4
    >>> with pl.Config(fmt_str_lengths=36):
    ...     df = pl.DataFrame(
    ...         {
    ...             "idx": [0, 1],
    ...             "uuid_obj": [uuid4(), uuid4()],
    ...             "uuid_str": [str(uuid4()), str(uuid4())],
    ...         },
    ...         schema_overrides={"idx": pl.Int32},
    ...     )
    ...     print(df)  # doctest: +IGNORE_RESULT
    shape: (2, 3)
    âââââââŹâââââââââââââââââââââââââââââââââââââââŹâââââââââââââââââââââââââââââââââââââââ
    â idx â uuid_obj                             â uuid_str                             â
    â --- â ---                                  â ---                                  â
    â i32 â object                               â str                                  â
    âââââââŞâââââââââââââââââââââââââââââââââââââââŞâââââââââââââââââââââââââââââââââââââââĄ
    â 0   â 6be063cf-c9c6-43be-878e-e446cfd42981 â acab9fea-c05d-4b91-b639-418004a63f33 â
    â 1   â 7849d8f9-2cac-48e7-96d3-63cf81c14869 â 28c65415-8b7d-4857-a4ce-300dca14b12b â
    âââââââ´âââââââââââââââââââââââââââââââââââââââ´âââââââââââââââââââââââââââââââââââââââ

    Select object columns and export as a dict:

    >>> df.select(cs.object()).to_dict(as_series=False)  # doctest: +IGNORE_RESULT
    {
        "uuid_obj": [
            UUID("6be063cf-c9c6-43be-878e-e446cfd42981"),
            UUID("7849d8f9-2cac-48e7-96d3-63cf81c14869"),
        ]
    }

    Select all columns *except* for those that are object and export as dict:

    >>> df.select(~cs.object())  # doctest: +IGNORE_RESULT
    {
        "idx": [0, 1],
        "uuid_str": [
            "acab9fea-c05d-4b91-b639-418004a63f33",
            "28c65415-8b7d-4857-a4ce-300dca14b12b",
        ],
    }
    Úobjectr	  )rN   r
  r  r   rQ   rU   rT   r^  r^  H	  s    ôj AEE¤&M°Ô9Đ9rU   c                 ój    t        | Ť      }d| d}t        t        j                  |Ť      dd| iŹŤ      S )uL  
    Select columns that start with the given substring(s).

    Parameters
    ----------
    prefix
        Substring(s) that matching column names should start with.

    See Also
    --------
    contains : Select all columns that contain the given substring.
    ends_with : Select all columns that end with the given substring(s).
    matches : Select all columns that match the given regex pattern.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": [1.0, 2.0],
    ...         "bar": [3.0, 4.0],
    ...         "baz": [5, 6],
    ...         "zap": [7, 8],
    ...     }
    ... )

    Match columns starting with a 'b':

    >>> df.select(cs.starts_with("b"))
    shape: (2, 2)
    âââââââŹââââââ
    â bar â baz â
    â --- â --- â
    â f64 â i64 â
    âââââââŞââââââĄ
    â 3.0 â 5   â
    â 4.0 â 6   â
    âââââââ´ââââââ

    Match columns starting with *either* the letter 'b' or 'z':

    >>> df.select(cs.starts_with("b", "z"))
    shape: (2, 3)
    âââââââŹââââââŹââââââ
    â bar â baz â zap â
    â --- â --- â --- â
    â f64 â i64 â i64 â
    âââââââŞââââââŞââââââĄ
    â 3.0 â 5   â 7   â
    â 4.0 â 6   â 8   â
    âââââââ´ââââââ´ââââââ

    Match all columns *except* for those starting with 'b':

    >>> df.select(~cs.starts_with("b"))
    shape: (2, 2)
    âââââââŹââââââ
    â foo â zap â
    â --- â --- â
    â f64 â i64 â
    âââââââŞââââââĄ
    â 1.0 â 7   â
    â 2.0 â 8   â
    âââââââ´ââââââ
    r   r4  rI   z*prefixr  r5  )ÚprefixÚescaped_prefixr8  s      rT   rI   rI   	  sB    ôD   Ó'NŘ^Đ$ CĐ(JäÜ	jÓŘŘvĐ&ôđ rU   )Úinclude_categoricalc                ó    t         g}| r|j                  t        Ť       t        t	        j
                  |Ť      dd| iŹŤ      S )un  
    Select all String (and, optionally, Categorical) string columns.

    See Also
    --------
    binary : Select all binary columns.
    by_dtype : Select all columns matching the given dtype(s).
    categorical: Select all categorical columns.

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "w": ["xx", "yy", "xx", "yy", "xx"],
    ...         "x": [1, 2, 1, 4, -2],
    ...         "y": [3.0, 4.5, 1.0, 2.5, -2.0],
    ...         "z": ["a", "b", "a", "b", "b"],
    ...     },
    ... ).with_columns(
    ...     z=pl.col("z").cast(pl.Categorical("lexical")),
    ... )

    Group by all string columns, sum the numeric columns, then sort by the string cols:

    >>> df.group_by(cs.string()).agg(cs.numeric().sum()).sort(by=cs.string())
    shape: (2, 3)
    âââââââŹââââââŹââââââ
    â w   â x   â y   â
    â --- â --- â --- â
    â str â i64 â f64 â
    âââââââŞââââââŞââââââĄ
    â xx  â 0   â 2.0 â
    â yy  â 6   â 7.0 â
    âââââââ´ââââââ´ââââââ

    Group by all string *and* categorical columns:

    >>> df.group_by(cs.string(include_categorical=True)).agg(cs.numeric().sum()).sort(
    ...     by=cs.string(include_categorical=True)
    ... )
    shape: (3, 4)
    âââââââŹââââââŹââââââŹâââââââ
    â w   â z   â x   â y    â
    â --- â --- â --- â ---  â
    â str â cat â i64 â f64  â
    âââââââŞââââââŞââââââŞâââââââĄ
    â xx  â a   â 2   â 4.0  â
    â xx  â b   â -2  â -2.0 â
    â yy  â b   â 6   â 7.0  â
    âââââââ´ââââââ´ââââââ´âââââââ
    rJ   rb  r  )r   rl   r   rN   r
  r  )rb  Ústring_dtypess     rT   rJ   rJ   Ě	  sB    ôj ,2¨(MŮŘ×Ń[Ô)äÜ	mÓŘŘ)Đ+>Đ?ôđ rU   c                 óJ    t        t        j                  t        Ť      dŹŤ      S )u]  
    Select all temporal columns.

    See Also
    --------
    by_dtype : Select all columns matching the given dtype(s).
    date : Select all date columns.
    datetime : Select all datetime columns, optionally filtering by time unit/zone.
    duration : Select all duration columns, optionally filtering by time unit.
    time : Select all time columns.

    Examples
    --------
    >>> from datetime import date, time
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "dt": [date(2021, 1, 1), date(2021, 1, 2)],
    ...         "tm": [time(12, 0, 0), time(20, 30, 45)],
    ...         "value": [1.2345, 2.3456],
    ...     }
    ... )

    Match all temporal columns:

    >>> df.select(cs.temporal())
    shape: (2, 2)
    ââââââââââââââŹâââââââââââ
    â dt         â tm       â
    â ---        â ---      â
    â date       â time     â
    ââââââââââââââŞâââââââââââĄ
    â 2021-01-01 â 12:00:00 â
    â 2021-01-02 â 20:30:45 â
    ââââââââââââââ´âââââââââââ

    Match all temporal columns *except* for time columns:

    >>> df.select(cs.temporal() - cs.time())
    shape: (2, 1)
    ââââââââââââââ
    â dt         â
    â ---        â
    â date       â
    ââââââââââââââĄ
    â 2021-01-01 â
    â 2021-01-02 â
    ââââââââââââââ

    Match all columns *except* for temporal columns:

    >>> df.select(~cs.temporal())
    shape: (2, 1)
    ââââââââââ
    â value  â
    â ---    â
    â f64    â
    ââââââââââĄ
    â 1.2345 â
    â 2.3456 â
    ââââââââââ
    rK   r	  )rN   r
  r  r"   rQ   rU   rT   rK   rK   
  s    ô~ AEE¤/Ó2¸ÔDĐDrU   c                 óJ    t        t        j                  t        Ť      dŹŤ      S )u  
    Select all time columns.

    See Also
    --------
    date : Select all date columns.
    datetime : Select all datetime columns, optionally filtering by time unit/zone.
    duration : Select all duration columns, optionally filtering by time unit.
    temporal : Select all temporal columns.

    Examples
    --------
    >>> from datetime import date, datetime, time
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "dtm": [datetime(2001, 5, 7, 10, 25), datetime(2031, 12, 31, 0, 30)],
    ...         "dt": [date(1999, 12, 31), date(2024, 8, 9)],
    ...         "tm": [time(0, 0, 0), time(23, 59, 59)],
    ...     },
    ... )

    Select all time columns:

    >>> df.select(cs.time())
    shape: (2, 1)
    ââââââââââââ
    â tm       â
    â ---      â
    â time     â
    ââââââââââââĄ
    â 00:00:00 â
    â 23:59:59 â
    ââââââââââââ

    Select all columns *except* for those that are times:

    >>> df.select(~cs.time())
    shape: (2, 2)
    âââââââââââââââââââââââŹâââââââââââââ
    â dtm                 â dt         â
    â ---                 â ---        â
    â datetime[Îźs]        â date       â
    âââââââââââââââââââââââŞâââââââââââââĄ
    â 2001-05-07 10:25:00 â 1999-12-31 â
    â 2031-12-31 00:30:00 â 2024-08-09 â
    âââââââââââââââââââââââ´âââââââââââââ
    rL   r	  )rN   r
  r  r   rQ   rU   rT   rL   rL   N
  r:  rU   )rS   rN   r÷   zLiteral[True])rS   r   r÷   zLiteral[False])rS   r   r÷   Úbool)rg   z4DataFrame | LazyFrame | Mapping[str, PolarsDataType]rh   rú   r[   rg  r÷   ztuple[str, ...])rm   zDataFrame | LazyFramern   r   r÷   z	list[Any])ry   r&   rz   zMapping[Any, Any] | Noner{   rg  r|   rg  rt   rg  r÷   r   )rn   zcstr | Expr | PolarsDataType | SelectorType | Collection[str | Expr | PolarsDataType | SelectorType]r   z*str | Expr | PolarsDataType | SelectorTyper÷   r*   )rJ   ústr | Collection[str]r   rg  r÷   r   )r÷   r*   )F)r  rg  r  rg  r÷   r*   )r   zUPolarsDataType | PythonDataType | Iterable[PolarsDataType] | Iterable[PythonDataType]r÷   r*   )r&  z#int | range | Sequence[int | range]r÷   r*   )r   rh  r)  rg  r÷   r*   )r6  r   r÷   r*   )N)rş   N)r@  ú&TimeUnit | Collection[TimeUnit] | NonerA  z9str | timezone | Collection[str | timezone | None] | Noner÷   r*   )r  rg  r÷   r*   rP   )r@  ri  r÷   r*   )rK  r   r÷   r*   )rN  zcstr | PolarsDataType | SelectorType | Expr | Collection[str | PolarsDataType | SelectorType | Expr]rO  z*str | PolarsDataType | SelectorType | Exprr÷   r*   )rY  r   r÷   r*   )r`  r   r÷   r*   )rb  rg  r÷   r*   )`Ú
__future__r   Úcollections.abcr   r   r   r:   r   Ú	functoolsr   Úoperatorr	   Útypingr
   r   r   r   r   Úpolarsr   r
  Úpolars._utils.parse.exprr   Úpolars._utils.variousr   r   Úpolars.datatypesr   r   r   r   r   r   r   r   r   r   r   Úpolars.datatypes.groupr   r   r    r!   r"   r#   Úpolars.exprr$   Úsysr%   r&   r'   Úpolars._typingr(   r)   r*   r+   Úversion_infor.   Útyping_extensionsÚ__all__rD   r@   rs   r   r   rN   r  r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r;   r<   r=   r>   r?   rA   rB   rC   rH   rM   rE   rF   rG   r^  rI   rJ   rK   rL   rQ   rU   rT   ú<module>rz     sá  đÝ "ç 9Ń 9Ý Ý Ý ÷ő ő "Ý >ß 6÷÷ ÷ ń ÷÷ ő áŰÝ(ç+ßUÓUŕ
×Ń7Ň"Ţĺ*ň đF 
Ú <ó 
Ř <đ 
Ú 0ó 
Ř 0óHđ. ń	L;Ř@đL;ŕ!đL;đ đ	L;đ
 óL;ób đR ńŘđŕđđ đ	đ
 đđ đđ óđ23!đ	Ađ3!đ <đ3!đ ó3!ôlM/tô M/đ` AEő ó/1đdl¸Uő lđ` đađ  ńaŘđađ đađ ó	aóH!:óH7<đtUđ	#đUđ óUópbđJ @Dő cóL/DódIóX16đj 9=đNđYŘ5đYŕIđYđ óYóx2<ôjXDđx 9=đlŘ5đlŕóló^IđX@9đ	Ađ@9đ >đ@9đ ó@9óF/5ód2?ój2Cój>QóB@UóF/3ódF
óR3Cól5:ópIđX +0ő =ó@?EôD16rU   