o
    š­§if ă                   @  sş  d dl mZ d dlZd dlZd dl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  mZ d dl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, d dl-m.Z. e /e0Ą d dl1m2Z2m3Z3 W d   n1 sw   Y  d dl4m5Z5 er´d dlm6Z6 d dlm7Z7m8Z8 d dl9m:Z:m;Z;m<Z< g d˘Z=edŽddZ>edŻddZ>d°ddZ>dd dąd'd(Z?d˛d-d.Z@d/d0dłd9d:ZAd´d>d?ZBG d@d de.ZCddAdľdFdGZDdśdHdIZEdˇd/dJd¸dMdNZF	/dˇd/dJd¸dOdPZGdśdQdRZHdśdSdTZIdšdWdXZJddYdşd]d^ZKddYdťd`daZLdśdbdcZMe! dśdddeZNe! dźd˝dhdiZOe! dźddjdždndoZPe! dśdpdqZQe! dśdrdsZRdśdtduZSdżdwdxZTdśdydzZU		{dŔdÁddZdśddZ
dˇdÂddZV	dźdĂddZWdÄddZXdĹddZYdd dĆddZZdśddZ[dśddZ\dśddZ]dśddZ^dd dĆddZ_dÇddZ`dśd dĄZadśd˘dŁZbdČdĽdŚZcd/d§dÉdŠdBZddśdŞdŤZedśdŹd­ZfdS )Ęé    )ÚannotationsN)Ú
CollectionÚMappingÚSequence)ÚDecimal)Úreduce)Úor_)ÚTYPE_CHECKINGÚAnyÚLiteralÚNoReturnÚoverload)Ú	functions)Ú_parse_inputs_as_iterable)Úunstable)Ú	is_columnÚ	re_escape)ÚBinaryÚBooleanÚCategoricalÚDateÚStringÚTimeÚis_polars_dtype)ÚExpr)ÚPyExprÚ
PySelector)ÚNoneType)ÚIterable)Ú	DataFrameÚ	LazyFrame)ÚPolarsDataTypeÚPythonDataTypeÚTimeUnit)%ÚSelectorÚallÚalphaÚalphanumericÚarrayÚbinaryÚbooleanÚby_dtypeÚby_indexÚby_nameÚcategoricalÚcontainsÚdateÚdatetimeÚdecimalÚdigitÚdurationÚ	ends_withÚenumÚexcludeÚexpand_selectorÚfirstÚfloatÚintegerÚis_selectorÚlastÚlistÚmatchesÚnestedÚnumericÚsigned_integerÚstarts_withÚstringÚstructÚtemporalÚtimeÚunsigned_integerÚobjr$   ÚreturnúLiteral[True]c                 C  ó   d S ŠNŠ ŠrI   rN   rN   úG/home/app/Keep/.python/lib/python3.10/site-packages/polars/selectors.pyr<   X   ó   r<   r
   úLiteral[False]c                 C  rL   rM   rN   rO   rN   rN   rP   r<   \   rQ   Úboolc                 C  s
   t | t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
    )Ú
isinstancer$   rO   rN   rN   rP   r<   `   s   
TŠÚstrictÚtargetú4DataFrame | LazyFrame | Mapping[str, PolarsDataType]ÚselectorúSelector | ExprrV   útuple[str, ...]c                C  sb   t | trddlm} || d} |rt|s(n|jjdds(d|d}t|t|  	|Ą 
Ą 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   )ZschemaF)Zallow_aliasingzexpected a selector; found ú	 instead.)rT   r   Zpolars.dataframer   r<   ÚmetaZis_column_selectionÚ	TypeErrorÚtupleÚselectZcollect_schema)rW   rY   rV   r   ÚmsgrN   rN   rP   r8   r   s   
?
ţ˙ýr8   ÚframeúDataFrame | LazyFrameÚitemsúbuiltins.list[Any]c                 G  sB   t |}g }|D ]}t|rt| |}| |Ą q| |Ą q|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   r<   r8   ÚextendÚappend)rb   rd   Z
items_iterÚexpandedÚitemZselector_colsrN   rN   rP   Ú_expand_selectorsĂ   s   
rj   F)Ú
tuple_keysÚdfr   ÚdúMapping[Any, Any] | NoneÚexpand_keysÚexpand_valuesrk   údict[str, Any]c          	      C  s   i }|pi   Ą D ]7\}}|rt|rt| |d||< || }|r;t|r;t| |d}|r1|||< q| t ||ĄĄ q|||< q|S )zCExpand dict key/value selectors into their underlying column names.)rY   )rd   r<   r8   ÚupdateÚdictÚfromkeys)	rl   rm   ro   rp   rk   rh   ÚkeyÚvalueÚcolsrN   rN   rP   Ú_expand_selector_dictsć   s   	

rx   ú[str | Expr | PolarsDataType | Selector | Collection[str | Expr | PolarsDataType | Selector]Ú
more_itemsú&str | Expr | PolarsDataType | Selectorc           	      G  sH  g g g }}}g }g t | trt | ts| n| g˘|˘R D ]G}t|r*| |Ą qt|r4| |Ą qt |trO| dĄrI| dĄrI| |Ą q| |Ą qt|r\| |j	 
Ą Ą qd|d}t|g }|rt| t|ddiĄ |r}| t| Ą |r| tt|dkrd d	d
 |D Ąn|d Ą |r| |Ą 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\   Úrequire_allFé   ú|c                 s  s    | ]	}d | dV  qdS )ú(ú)NrN   )Ú.0ÚrxrN   rN   rP   Ú	<genexpr>+  s    z'_combine_as_selector.<locals>.<genexpr>r   )rT   r   Ústrr<   rg   r   Ú
startswithÚendswithr   r]   Úoutput_namer^   r-   r+   r?   ÚlenÚjoinrf   r   r   )	rd   rz   ÚnamesÚregexesÚdtypesÚ	selectorsri   ra   ÚselectedrN   rN   rP   Ú_combine_as_selector˙   sN   ˙˙ü
ú
˙ý˙

r   c                   @  sb  e Zd ZU dZdZded< edLddZdMd
dZdNddZ	dOddZ
dPddZedQddZedRdd ZdSd!d"ZdTd&d'ZdTd(d)ZedUd*d+ZedTd,d+ZdVd.d+ZdTd/d0ZedUd1d2ZedTd3d2ZdVd4d2ZdTd5d6ZedUd7d8ZedTd9d8ZdVd:d8ZdWd<d=ZedUd>d?ZedTd@d?ZdVdAd?ZdTdBdCZdXdHdIZdYdJdKZdS )Zr$   z&Base column selector expression/proxy.Nr   Ú_pyselectorÚ
pyselectorrJ   c                 C  s   |  }||_ t |Ą|_|S rM   )r   r   Znew_selectorÚ_pyexpr)Úclsr   ZslfrN   rN   rP   Ú_from_pyselector<  s   zSelector._from_pyselectorÚbytesc                 C  ó
   | j  Ą S rM   )r   Ú__getstate__ŠÚselfrN   rN   rP   r   C  s   
zSelector.__getstate__ÚstateÚNonec                 C  s,   t  dĄj| _| j |Ą | j Ą j| _d S )Nr   )ÚFZlitr   Ú__setstate__r]   Zas_selectorr   )r   r   rN   rN   rP   r   F  s   zSelector.__setstate__r   c                 C  s   t t | jĄS rM   )r   r   Ú_from_pyexprr   r   rN   rN   rP   Ú__repr__K  s   zSelector.__repr__Úintc                 C  r   rM   )r   Úhashr   rN   rN   rP   Ú__hash__N  s   
zSelector.__hash__r   ú.builtins.list[PythonDataType | PolarsDataType]c                 C  sv  g }g }|D ]}t |r|tju r|t g7 }qt|tjr/|jdkr/|t|jddg7 }q|tju r;|t g7 }q|tj	u rG|t
 g7 }q|tju rS|t g7 }q|tju r_|t g7 }q|tju rk|t g7 }q|tju rw|t g7 }q|tju r|t g7 }q||g7 }qt|tr^|tu r|t g7 }q|tju rŚ|t g7 }q|tu rą|t g7 }q|tu r˝|t Ą g7 }q|tu rÉ|t Ą g7 }q|t u rÔ|t  g7 }q|t!u rŕ|t "Ą g7 }q|t#j$u rí|t %Ą g7 }q|t#ju rů|t g7 }q|t#j&u r|t g7 }q|t#j'u r|t' g7 }q|t(u r|t g7 }q|tju s*|t)u r1|t g7 }qtt*tu r:t*ndtt*j+}tt*tu rKdndt*d}d| d| }t,|d tt*tu rgt*ndtt*j+}tt*tu rxdndt*d}d| d| }t,|d |  -t. /|ĄĄ}t0|d	kr|S |d	 }	|d
d  D ]}
|	|
B }	qŚt0|d	krˇ|	S ||	B S )NÚ*)Ú	time_unitÚ	time_zonezof type Ú z	 (given: r   zcannot parse input z into Polars selectorr   r   )1r   ÚpldtZDatetimer1   rT   r¨   r§   ZDurationr4   r   r.   ÚEnumr6   ÚListr>   ZArrayr(   ÚStructrE   r   r2   Útyper˘   r;   Úbuiltinsr:   rS   r*   r   r   r   r   Úobjectr   ZNullÚ
pydatetimerG   r   Ú	timedeltar0   Ú	PyDecimalr_   ÚinputÚ__name__r^   r   r   r+   r   )r   r   r   Zconcrete_dtypesÚdtZ
input_typeZinput_detailra   Zdtype_selectorrY   ÚsrN   rN   rP   Ú	_by_dtypeS  s   












˙ý
˙ý
zSelector._by_dtyper   úbuiltins.list[str]rV   rS   Úexpand_patternsc                C  s   |   t |||ĄĄS rM   )r   r   r-   )r   r   rV   rş   rN   rN   rP   Ú_by_nameŞ  s   zSelector._by_namec                 C  s
   t  |  S )zInvert the selector.)r%   )r   rN   rN   rP   Ú
__invert__°  s   
zSelector.__invert__Úotherr
   r   c                 C  s(   t |r|  Ą  | Ą ĄS |  Ą  |ĄS rM   )r<   Úas_exprÚ__add__Šr   r˝   rN   rN   rP   rż   ´  s   zSelector.__add__c                 C  s"   t |r
d}t||  Ą  |ĄS )Nz=unsupported operand type(s) for op: ('Selector' + 'Selector'))r<   r^   rž   Ú__radd__Šr   r˝   ra   rN   rN   rP   rÁ   ş  s   zSelector.__radd__c                 C  rL   rM   rN   rŔ   rN   rN   rP   Ú__and__Á  rQ   zSelector.__and__c                 C  rL   rM   rN   rŔ   rN   rN   rP   rĂ   Ä  rQ   rZ   c                 C  sF   t |r|j Ą }t|}t|rt t | j	|j	ĄĄS |  
Ą  |ĄS rM   )r   r]   r   r-   r<   r$   r   r   Z	intersectr   rž   rĂ   )r   r˝   ZcolnamerN   rN   rP   rĂ   Ç  s   
˙c                 C  s   |   Ą  |ĄS rM   )rž   Ú__rand__rŔ   rN   rN   rP   rÄ   Ň  s   zSelector.__rand__c                 C  rL   rM   rN   rŔ   rN   rN   rP   Ú__or__Ő  rQ   zSelector.__or__c                 C  rL   rM   rN   rŔ   rN   rN   rP   rĹ   Ř  rQ   c                 C  óB   t |rt|j Ą }t|rt t | j	|j	ĄĄS |  
Ą  |ĄS rM   )r   r-   r]   r   r<   r$   r   r   Úunionr   rž   rĹ   rŔ   rN   rN   rP   rĹ   Ű  ó   ˙c                 C  ó$   t |rt|j Ą }|  Ą  |ĄS rM   )r   r-   r]   r   rž   Ú__ror__rŔ   rN   rN   rP   rĘ   ĺ  ó   zSelector.__ror__c                 C  rL   rM   rN   rŔ   rN   rN   rP   Ú__sub__ę  rQ   zSelector.__sub__c                 C  rL   rM   rN   rŔ   rN   rN   rP   rĚ   í  rQ   c                 C  s,   t |rt t | j|jĄĄS |  Ą  |ĄS rM   )r<   r$   r   r   Ú
differencer   rž   rĚ   rŔ   rN   rN   rP   rĚ   đ  s
   ˙r   c                 C  s   d}t |)Nz9unsupported operand type(s) for op: ('Expr' - 'Selector'))r^   rÂ   rN   rN   rP   Ú__rsub__ř  s   zSelector.__rsub__c                 C  rL   rM   rN   rŔ   rN   rN   rP   Ú__xor__ü  rQ   zSelector.__xor__c                 C  rL   rM   rN   rŔ   rN   rN   rP   rĎ   ˙  rQ   c                 C  rĆ   rM   )r   r-   r]   r   r<   r$   r   r   Zexclusive_orr   rž   rĎ   rŔ   rN   rN   rP   rĎ     rČ   c                 C  rÉ   rM   )r   r-   r]   r   rž   Ú__rxor__rŔ   rN   rN   rP   rĐ     rË   zSelector.__rxor__Úcolumnsú7str | PolarsDataType | Collection[str | PolarsDataType]Úmore_columnsústr | PolarsDataTypec                 G  sŞ   g }g }g t |trt |ts|n|g˘|˘R D ] }t |tr%| |Ą qt|r/| |Ą qd|d}t||rC|rCd}t||rIt|ntj|ddd}| | S )aV  
        Exclude columns from a multi-column expression.

        Only works after a wildcard or regex column selection, and you cannot provide
        both string column names *and* dtypes (you may prefer to use selectors instead).

        Parameters
        ----------
        columns
            The name or datatype of the column(s) to exclude. Accepts regular expression
            input. Regular expressions should start with `^` and end with `$`.
        *more_columns
            Additional names or datatypes of columns to exclude, specified as positional
            arguments.
        zMinvalid input for `exclude`

Expected one or more `str` or `DataType`; found r\   z,cannot exclude by both column name and dtypeFTŠrV   rş   )	rT   r   r   rg   r   r^   r+   r$   rť   )r   rŃ   rÓ   Zexclude_colsZexclude_dtypesri   ra   ÚexcludedrN   rN   rP   r7     s@   ˙˙ü
ú
˙˙
˙ýý	zSelector.excludec                 C  s   t  | 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   r    r   r   rN   rN   rP   rž   I  s   /zSelector.as_expr)r   r   rJ   r$   )rJ   r   )r   r   rJ   r   )rJ   r   )rJ   r˘   )r   rĽ   rJ   r$   )r   rš   rV   rS   rş   rS   rJ   r$   ŠrJ   r$   )r˝   r
   rJ   r   )r˝   r$   rJ   r$   )r˝   r
   rJ   rZ   )r˝   r
   rJ   r   )rŃ   rŇ   rÓ   rÔ   rJ   r$   )rJ   r   )rľ   Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__Úclassmethodr   r   r   rĄ   r¤   r¸   rť   rź   rż   rÁ   r   rĂ   rÄ   rĹ   rĘ   rĚ   rÎ   rĎ   rĐ   r7   rž   rN   rN   rN   rP   r$   6  sT   
 



V













8ŠÚescaperD   ústr | Collection[str]rŢ   r   c                  sx   t | tr rt| n| }n(g }| D ]}t |tr$t |ts$| |Ą q| |Ą qd  fdd|D Ą}d| dS )zIReturn escaped regex, potentially representing multiple string fragments.r   c                 3  s     | ]} r
t |n|V  qd S rM   )r   )r   ÚxrÝ   rN   rP   r     s    z_re_string.<locals>.<genexpr>r   r   )rT   r   r   r   rf   rg   r   )rD   rŢ   r   ÚstringsÚstrN   rÝ   rP   Ú
_re_string{  s   
ră   c                   C  ó   t  t Ą Ą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   r   r%   rN   rN   rN   rP   r%     ó   /r%   )Úignore_spacesÚ
ascii_onlyrć   c                C  s4   | rdnd}|r
dnd}t  t 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Š   ú^[ú]+$Šr$   r   r   r?   )rç   rć   Úre_alphaÚre_spacerN   rN   rP   r&   ź  s   fr&   c             	   C  sD   | rdnd}| r
dnd}|rdnd}t  t 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ě   rí   )rç   rć   rî   Úre_digitrď   rN   rN   rP   r'   '  s   Z˙r'   c                   C  ó
   t tg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': [':)']}
    )r+   r   rN   rN   rN   rP   r)     s   
!r)   c                   C  rň   )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   â
    âââââââ
    )r+   r   rN   rN   rN   rP   r*   ­  s   
7r*   r   úUPolarsDataType | PythonDataType | Iterable[PolarsDataType] | Iterable[PythonDataType]c                  G  s   g }| D ];}t |st|tr| |Ą qt|tr7|D ]}t |s0t|ts0d|}t|| |Ą qqd|}t|t |Ą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: )r   rT   rŽ   rg   r   r^   r$   r¸   )r   Z
all_dtypesÚtpÚtra   rN   rN   rP   r+   ç  s   E

ü

r+   )r~   Úindicesú#int | range | Sequence[int | range]r~   c                 G  s`   g }|D ]"}t |ttfr| |Ą qt |tr| |Ą qd|}t|t t	 
|| ĄĄS )uM  
    Select all columns matching the given indices (or range objects).

    Parameters
    ----------
    *indices
        One or more column indices (or range objects).
        Negative indexing is supported.
    require_all
        By default, all specified indices must be valid; if any index is out of bounds,
        an error is raised. If set to `False`, out-of-bounds indices are ignored

    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), require_all=False))
    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: )rT   Úranger   rf   r˘   rg   r^   r$   r   r   r,   )r~   rö   Zall_indicesÚidxra   rN   rN   rP   r,   =  s   [

r,   r   c                 G  s   g }|D ]3}t |tr| |Ą qt |tr/|D ]}t |ts(d|}t|| |Ą qqd|}t|tj|| d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.
    matches: Select columns matching the given regex pattern.

    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)
    âââââââŹââââââ
    â baz â foo â
    â --- â --- â
    â f64 â str â
    âââââââŞââââââĄ
    â 2.0 â x   â
    â 5.5 â y   â
    âââââââ´ââââââ

    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: FrŐ   )rT   r   rg   r   r^   r$   rť   )r~   r   Z	all_namesÚnmÚnra   rN   rN   rP   r-   Ľ  s   L



ü
r-   c                   C  rä   )uR  
    Select no columns.

    This is useful for composition with other selectors.

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

    Examples
    --------
    >>> import polars.selectors as cs
    >>> pl.DataFrame({"a": 1, "b": 2}).select(cs.empty())
    shape: (0, 0)
    ââ
    ââĄ
    ââ
    )r$   r   r   ÚemptyrN   rN   rN   rP   rü     s   rü   c                   C  rä   )u%  
    Select all enum columns.

    .. warning::
        This functionality is considered **unstable**. It may be changed
        at any point without it being considered a breaking change.

    See Also
    --------
    by_dtype : Select all columns matching the given dtype(s).
    categorical : Select all categorical columns.
    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.Enum(["xx", "yy"])},
    ... )

    Select all enum columns:

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

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

    >>> df.select(~cs.enum())
    shape: (2, 2)
    âââââââŹââââââ
    â bar â baz â
    â --- â --- â
    â i64 â f64 â
    âââââââŞââââââĄ
    â 123 â 2.0 â
    â 456 â 5.5 â
    âââââââ´ââââââ
    )r$   r   r   Zenum_rN   rN   rN   rP   r6     ó   5r6   ÚinnerúNone | Selectorc                 C  s"   | dur| j nd}t t |ĄĄS )u%  
    Select all list columns.

    .. warning::
        This functionality is considered **unstable**. It may be changed
        at any point without it being considered a breaking change.

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

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

    Select all list columns:

    >>> df.select(cs.list())
    shape: (2, 1)
    ââââââââââââââââ
    â foo          â
    â ---          â
    â list[str]    â
    ââââââââââââââââĄ
    â ["xx", "yy"] â
    â ["x"]        â
    ââââââââââââââââ

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

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

    Select all list columns with a certain matching inner type:

    >>> df.select(cs.list(cs.string()))
    shape: (2, 1)
    ââââââââââââââââ
    â foo          â
    â ---          â
    â list[str]    â
    ââââââââââââââââĄ
    â ["xx", "yy"] â
    â ["x"]        â
    ââââââââââââââââ
    >>> df.select(cs.list(cs.integer()))
    shape: (0, 0)
    ââ
    ââĄ
    ââ
    N)r   r$   r   r   r>   )rţ   Úinner_srN   rN   rP   r>   P  s   Fr>   )ÚwidthúSelector | Noner  ú
int | Nonec                C  s$   | dur| j nd}t t ||ĄĄS )uC	  
    Select all array columns.

    .. warning::
        This functionality is considered **unstable**. It may be changed
        at any point without it being considered a breaking change.

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

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

    Select all array columns:

    >>> df.select(cs.array())
    shape: (2, 1)
    âââââââââââââââââ
    â foo           â
    â ---           â
    â array[str, 2] â
    âââââââââââââââââĄ
    â ["xx", "yy"]  â
    â ["x", "y"]    â
    âââââââââââââââââ

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

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

    Select all array columns with a certain matching inner type:

    >>> df.select(cs.array(cs.string()))
    shape: (2, 1)
    âââââââââââââââââ
    â foo           â
    â ---           â
    â array[str, 2] â
    âââââââââââââââââĄ
    â ["xx", "yy"]  â
    â ["x", "y"]    â
    âââââââââââââââââ
    >>> df.select(cs.array(cs.integer()))
    shape: (0, 0)
    ââ
    ââĄ
    ââ
    >>> df.select(cs.array(width=2))
    shape: (2, 1)
    âââââââââââââââââ
    â foo           â
    â ---           â
    â array[str, 2] â
    âââââââââââââââââĄ
    â ["xx", "yy"]  â
    â ["x", "y"]    â
    âââââââââââââââââ
    >>> df.select(cs.array(width=3))
    shape: (0, 0)
    ââ
    ââĄ
    ââ
    N)r   r$   r   r   r(   )rţ   r  r   rN   rN   rP   r(     s   Vr(   c                   C  rä   )u[  
    Select all struct columns.

    .. warning::
        This functionality is considered **unstable**. It may be changed
        at any point without it being considered a breaking change.

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

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

    Select all struct columns:

    >>> df.select(cs.struct())
    shape: (2, 1)
    ââââââââââââââ
    â foo        â
    â ---        â
    â struct[2]  â
    ââââââââââââââĄ
    â {"xx","z"} â
    â {"x","y"}  â
    ââââââââââââââ

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

    >>> df.select(~cs.struct())
    shape: (2, 2)
    âââââââŹââââââ
    â bar â baz â
    â --- â --- â
    â i64 â f64 â
    âââââââŞââââââĄ
    â 123 â 2.0 â
    â 456 â 5.5 â
    âââââââ´ââââââ
    )r$   r   r   Zstruct_rN   rN   rN   rP   rE   ô  rý   rE   c                   C  rä   )ud  
    Select all nested columns.

    A nested column is a list, array or struct.

    .. warning::
        This functionality is considered **unstable**. It may be changed
        at any point without it being considered a breaking change.

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

    Examples
    --------
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "foo": [{"a": "xx", "b": "z"}, {"a": "x", "b": "y"}],
    ...         "bar": [123, 456],
    ...         "baz": [2.0, 5.5],
    ...         "wow": [[1, 2], [3]],
    ...     },
    ... )

    Select all nested columns:

    >>> df.select(cs.nested())
    shape: (2, 2)
    ââââââââââââââŹââââââââââââ
    â foo        â wow       â
    â ---        â ---       â
    â struct[2]  â list[i64] â
    ââââââââââââââŞââââââââââââĄ
    â {"xx","z"} â [1, 2]    â
    â {"x","y"}  â [3]       â
    ââââââââââââââ´ââââââââââââ

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

    >>> df.select(~cs.nested())
    shape: (2, 2)
    âââââââŹââââââ
    â bar â baz â
    â --- â --- â
    â i64 â f64 â
    âââââââŞââââââĄ
    â 123 â 2.0 â
    â 456 â 5.5 â
    âââââââ´ââââââ
    )r$   r   r   r@   rN   rN   rN   rP   r@   ,  s   8r@   c                   C  rä   )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 â
    âââââââ´ââââââ
    )r$   r   r   r.   rN   rN   rN   rP   r.   g  rĺ   r.   Ú	substringc                  G  s   t | }t t |ĄĄ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  â
    âââââââ´ââââââââ
    Šră   r$   r   r   r?   )r  ÚpatternrN   rN   rP   r/     s   Br/   c                   C  rň   )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 â
    âââââââââââââââââââââââ´âââââââââââ
    )r+   r   rN   rN   rN   rP   r0   ß  ó   
1r0   ŠrŚ   Nr§   ú&TimeUnit | Collection[TimeUnit] | Noner¨   úOstr | pydatetime.timezone | Collection[str | pydatetime.timezone | None] | Nonec                 C  sr   | du r	g d˘}nt | tr| gnt | Ą}|du rdg}n|r0t |ttjfr+|gnt |Ą}t t 	||ĄĄS )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Úns)
rT   r   rŻ   r>   rą   Útimezoner$   r   r   r1   )r§   r¨   Ztime_unit_lstZtime_zone_lstrN   rN   rP   r1     s    

˙˙ýr1   c                   C  rä   )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[38,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   r   r2   rN   rN   rN   rP   r2   °  ó   2r2   c                 C  s$   | rdnd}t  t 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ń   rN   rN   rP   r3   ĺ  s   Wr3   c                 C  s<   | du r	g d˘} nt | tr| gnt | Ą} t t | ĄĄS )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 â
    ââââââââââââââ
    Nr  )rT   r   rŻ   r>   r$   r   r   r4   )r§   rN   rN   rP   r4   @  s
   b
˙r4   Úsuffixc                  G  s   t |  d}t t |ĄĄ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  â
    âââââââ´ââââââ´ââââââââ
    r}   r  )r  r  rN   rN   rP   r5   Ź  ó   Br5   rŃ   ú[str | PolarsDataType | Selector | Expr | Collection[str | PolarsDataType | Selector | Expr]rÓ   ú&str | PolarsDataType | Selector | Exprc                 G  s   t | g|˘R   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   )rŃ   rÓ   rN   rN   rP   r7   ň  s   @r7   c                 C  ó   t  t | ĄĄ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   â
    âââââââ´ââââââ´ââââââ
    )r$   r   r   r9   rU   rN   rN   rP   r9   5	  ó   /r9   c                   C  rä   )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 â
    âââââââ´ââââââ
    )r$   r   r   r:   rN   rN   rN   rP   r:   g	  r  r:   c                   C  rä   )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 â
    âââââââ´ââââââ
    )r$   r   r   r;   rN   rN   rN   rP   r;   	  r  r;   c                   C  rä   )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 â
    ââââââââ´âââââââ´âââââââ
    )r$   r   r   rB   rN   rN   rN   rP   rB   Ń	  s   >rB   c                   C  rä   )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 â
    ââââââââ´âââââââ´âââââââ
    )r$   r   r   rH   rN   rN   rN   rP   rH   
  s   @rH   c                 C  r  )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 â
    âââââââ´ââââââ´ââââââ
    )r$   r   r   r=   rU   rN   rN   rP   r=   U
  r  r=   r  c                 C  sL   | dkrt  S |  dĄr| dd } n|  dĄr| dd } t t | ĄĄ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%   r   r   r$   r   r   r?   )r  rN   rN   rP   r?   
  s   6

r?   c                   C  rä   )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   â
    âââââââ
    )r$   r   r   rA   rN   rN   rN   rP   rA   Č
  s   3rA   c                   C  rä   )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",
        ],
    }
    )r$   r   r   r°   rN   rN   rN   rP   r°   ţ
  rý   r°   Úprefixc                  G  s   dt |  }t t |ĄĄ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|   r  )r  Zstarts_with_patternrN   rN   rP   rC   6  r  rC   )Úinclude_categoricalr  c                 C  s   t g}| r
| tĄ t|S )ue  
    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()),
    ... )

    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  â
    âââââââ´ââââââ´ââââââ´âââââââ
    )r   rg   r   r+   )r  Zstring_dtypesrN   rN   rP   rD   |  s   5
c                   C  rä   )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 â
    ââââââââââ
    )r$   r   r   rF   rN   rN   rN   rP   rF   ¸  s   ?rF   c                   C  rň   )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 â
    âââââââââââââââââââââââ´âââââââââââââ
    )r+   r   rN   rN   rN   rP   rG   ú  r  rG   )rI   r$   rJ   rK   )rI   r
   rJ   rR   )rI   r
   rJ   rS   )rW   rX   rY   rZ   rV   rS   rJ   r[   )rb   rc   rd   r
   rJ   re   )rl   r   rm   rn   ro   rS   rp   rS   rk   rS   rJ   rq   )rd   ry   rz   r{   rJ   r$   )rD   rß   rŢ   rS   rJ   r   r×   )F)rç   rS   rć   rS   rJ   r$   )r   ró   rJ   r$   )rö   r÷   r~   rS   rJ   r$   )r   rß   r~   rS   rJ   r$   rM   )rţ   r˙   rJ   r$   )rţ   r  r  r  rJ   r$   )r  r   rJ   r$   )Nr  )r§   r	  r¨   r
  rJ   r$   )rç   rS   rJ   r$   )r§   r	  rJ   r$   )r  r   rJ   r$   )rŃ   r  rÓ   r  rJ   r$   )rV   rS   rJ   r$   )r  r   rJ   r$   )r  r   rJ   r$   )r  rS   rJ   r$   )gÚ
__future__r   rŻ   Ú
contextlibr1   rą   Úcollections.abcr   r   r   r2   r   rł   Ú	functoolsr   Úoperatorr   Útypingr	   r
   r   r   r   Zpolars.datatypes.classesZ	datatypesÚclassesrŞ   Zpolarsr   r   Zpolars._utils.parse.exprr   Zpolars._utils.unstabler   Zpolars._utils.variousr   r   Zpolars.datatypesr   r   r   r   r   r   r   Zpolars.exprr   ÚsuppressÚImportErrorZpolars._plrr   r   Útypesr   r   r   r    Zpolars._typingr!   r"   r#   Ú__all__r<   r8   rj   rx   r   r$   ră   r%   r&   r'   r)   r*   r+   r,   r-   rü   r6   r>   r(   rE   r@   r.   r/   r0   r3   r4   r5   r7   r9   r:   r;   rB   rH   r=   r?   rA   r°   rC   rD   rF   rG   rN   rN   rN   rP   Ú<module>   s˛    $	˙+
ü
Q)ú
7  G
2l˙ý
b
$
:W˙h
]7IY7
:
2
F5ü 
5\˙
l
FC
2
5
5
AC
2
A
6
8F
<B