§
    q-PhW ć                  ó   d dl mZ d dlmZmZmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZmZmZmZmZ d dlmZ d dlmZ d d	lmZmZ d d
lmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z% d dl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, d dl-m.Z. er6d dl/Z/d dlm0Z0 d dlm1Z1m2Z2 d dl3m4Z4m5Z5m6Z6m7Z7 e/j8        dk    rd dlm9Z9 nd dl:m9Z9 g d¢Z;edzd¦   «         Z<ed{d¦   «         Z<d|dZ<ddd}d&Z=d~d+Z>d,d-dd6Z?dd;Z@ G d< de.¦  «        ZAdd=ddBZBddCZCdd,dDddGZD	 dd,dDddHZEddIZFddJZGddMZHddPZIddQddTZJddUZKddWZLddXZM	 	 ddd^Zdd_ZNddd`ZO	 dddaZPddcZQddhZRddiZSddjZTddkZUddlZVddmZWddnZXddpZYddqZZddrZ[ddtZ\d,duddwZ]ddxZ^ddyZ_dS )é    )Śannotations)Ś
CollectionŚMappingŚSequence)Śtimezone)Średuce)Śor_)ŚTYPE_CHECKINGŚAnyŚLiteralŚNoReturnŚoverload)Ś	functions)Ś_parse_inputs_as_iterable)Ś	is_columnŚ	re_escape)ŚBinaryŚBooleanŚCategoricalŚDateŚDatetimeŚDecimalŚDurationŚObjectŚStringŚTimeŚis_polars_dtype)ŚFLOAT_DTYPESŚINTEGER_DTYPESŚNUMERIC_DTYPESŚSIGNED_INTEGER_DTYPESŚTEMPORAL_DTYPESŚUNSIGNED_INTEGER_DTYPES)ŚExprN)ŚIterable)Ś	DataFrameŚ	LazyFrame)ŚPolarsDataTypeŚPythonDataTypeŚSelectorTypeŚTimeUnit)é   é   )ŚSelf)ŚallŚalphaŚalphanumericŚbinaryŚbooleanŚby_dtypeŚby_indexŚby_nameŚcategoricalŚcontainsŚdateŚdatetimeŚdecimalŚdigitŚdurationŚ	ends_withŚexcludeŚexpand_selectorŚfirstŚfloatŚintegerŚis_selectorŚlastŚmatchesŚnumericŚsigned_integerŚstarts_withŚstringŚtemporalŚtimeŚunsigned_integerŚobjŚ_selector_proxy_ŚreturnśLiteral[True]c                ó    d S ©N© ©rN   s    śP/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/selectors.pyrD   rD   X   s    Ų9<øó    r   śLiteral[False]c                ó    d S rS   rT   rU   s    rV   rD   rD   \   s    Ų-0ØSrW   Śboolc                óL    t          | t          ¦  «        ot          | d¦  «        S )a  
    Indicate whether the given object/expression is a selector.

    Examples
    --------
    >>> from polars.selectors import is_selector
    >>> import polars.selectors as cs
    >>> is_selector(pl.col("colx"))
    False
    >>> is_selector(cs.first() | cs.last())
    True
    Ś_attrs)Ś
isinstancerO   ŚhasattrrU   s    rV   rD   rD   `   s$    õ cÕ+Ń,Ō,ŠGµøøhŃ1GŌ1GŠGrW   T)ŚstrictŚtargetś4DataFrame | LazyFrame | Mapping[str, PolarsDataType]ŚselectorśSelectorType | Exprr_   śtuple[str, ...]c               ó<   t          | t          ¦  «        rddlm}  || ¬¦  «        } |rt	          |¦  «        s1n|j                             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&   )ŚschemaF)Śallow_aliasingzexpected a selector; found ś	 instead.)r]   r   Śpolars.dataframer&   rD   ŚmetaŚis_column_selectionŚ	TypeErrorŚtupleŚselectŚcollect_schema)r`   rb   r_   r&   Śmsgs        rV   r@   r@   s   s¼    õ~ &'Ń"Ō"š *Ų.Š.Š.Š.Š.Š.ą &Š)Ń)Ō)š šŻHŃŌšš š ]×.Ņ.øeŠ.ŃDŌDšš
 BØHŠAŠAŠAŻnnŠåxŃ(Ō(×7Ņ7Ń9Ō9Ń:Ō:Š:rW   ŚframeśDataFrame | LazyFrameŚitemsś	list[Any]c                óĘ    t          |¦  «        }g }|D ]L}t          |¦  «        r&t          | |¦  «        }|                     |¦  «         7|                     |¦  «         M|S )as  
    Internal function that expands any selectors to column names in the given input.

    Non-selector values are left as-is.

    Examples
    --------
    >>> from polars.selectors import _expand_selectors
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "colw": ["a", "b"],
    ...         "colx": ["x", "y"],
    ...         "coly": [123, 456],
    ...         "colz": [2.0, 5.5],
    ...     }
    ... )
    >>> _expand_selectors(df, ["colx", cs.numeric()])
    ['colx', 'coly', 'colz']
    >>> _expand_selectors(df, cs.string(), cs.float())
    ['colw', 'colx', 'colz']
    )r   rD   r@   ŚextendŚappend)rq   rs   Ś
items_iterŚexpandedŚitemŚselector_colss         rV   Ś_expand_selectorsr|   Ä   ss    õ. +Ø5Ń1Ō1JąHŲš "š "ŻtŃŌš 	"Ż+ØE°4Ń8Ō8MŲOOMŃ*Ō*Š*Š*ąOODŃ!Ō!Š!Š!ŲOrW   F)Ś
tuple_keysŚdfr&   ŚdśMapping[Any, Any] | NoneŚexpand_keysŚexpand_valuesr}   śdict[str, Any]c               óX   i }|pi                       ¦   «         D ]\  }}|r+t          |¦  «        rt          | |¬¦  «        ||<   ||         }|rWt          |¦  «        rHt          | |¬¦  «        }|r|||<   \|                     t                               ||¦  «        ¦  «         |||<   |S )zCExpand dict key/value selectors into their underlying column names.)rb   )rs   rD   r@   ŚupdateŚdictŚfromkeys)	r~   r   r   r   r}   ry   ŚkeyŚvalueŚcolss	            rV   Ś_expand_selector_dictsr   ē   sĻ    š HŲwBooŃ'Ō'š "š "
UŲš 	"[ØŃ/Ō/š 	"Ż+ØBøŠ?Ń?Ō?HSMŲSMEŲš 	"; sŃ+Ō+š 	"Ż" 2°Š4Ń4Ō4DŲš <Ų!&ą„§¢Ød°EŃ :Ō :Ń;Ō;Š;Š;ą!HSMMŲOrW   ścstr | Expr | PolarsDataType | SelectorType | Collection[str | Expr | PolarsDataType | SelectorType]Ś
more_itemsś*str | Expr | PolarsDataType | SelectorTyper*   c                ó   g g g g f\  }}}}g t          | t          ¦  «        rt          | t          ¦  «        s| n| g¢|¢R D ]}t          |¦  «        r|                     |¦  «         (t          |¦  «        r|                     |¦  «         Mt          |t          ¦  «        rV|                     d¦  «        r+|                     d¦  «        r|                     |¦  «         ¢|                     |¦  «         øt          |¦  «        r-|                     |j	         
                    ¦   «         ¦  «         ōd|d}t          |¦  «        g }|r|                     t          | ¦  «         |r|                     t          | ¦  «         |rZ|                     t          t          |¦  «        dk    r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 rh   é   ś|c              3  ó"   K   | ]
}d | dV  dS )ś(ś)NrT   )Ś.0Śrxs     rV   ś	<genexpr>z'_combine_as_selector.<locals>.<genexpr>+  s*   č č  Š5Š5 rRŠ5Š5Š5Š5Š5Š5rW   r   )r]   r   ŚstrrD   rw   r   Ś
startswithŚendswithr   rj   Śoutput_namerl   r6   r4   rF   ŚlenŚjoinrv   r   r	   )	rs   r   ŚnamesŚregexesŚdtypesŚ	selectorsrz   rp   Śselecteds	            rV   Ś_combine_as_selectorr„      s@   š )+ØB°°BØŃ%E7FIšõ %„Ń,Ō,šŻ5?ĄÅsŃ5KŌ5KšEEąš	š 
šš š !ń !õ tŃŌš 	!Ų×ŅTŃ"Ō"Š"Š"ŻTŃ"Ō"š 	!ŲMM$ŃŌŠŠŻcŃ"Ō"š 		!ŲsŃ#Ō#š #ØÆŖ°cŃ(:Ō(:š #ŲtŃ$Ō$Š$Š$ąTŃ"Ō"Š"Š"Żt__š 	!ŲLL×.Ņ.Ń0Ō0Ń1Ō1Š1Š1ą`ČtŠ`Š`Š`CŻC..Š ąHŲš )Ų Ń(Ō(Š(Ųš +Ų &Š)Ń*Ō*Š*Ųš 
ŲŻåw<< !Ņ#Š#š Š5Š5ØWŠ5Ń5Ō5Ń5Ō5Š5ąQZńō ń	
ō 	
š 	
š š #Ų	Ń"Ō"Š"å#xŃ Ō Š rW   c                  ó   e Zd ZU dZded<   ded<   	 d.d/dZd0dZd1dZd2dZe	d3d¦   «         Z
e	d4d¦   «         Z
d5dZ
d4dZe	d3d¦   «         Ze	d4d¦   «         Zd5dZd4dZe	d3d ¦   «         Ze	d4d!¦   «         Zd5d"Zd4d#Ze	d3d$¦   «         Ze	d5d%¦   «         Zd4d&Zd6d(Ze	d3d)¦   «         Ze	d4d*¦   «         Zd5d+Zd4d,Zd7d-ZdS )8rO   z&Base column selector expression/proxy.r   r\   r   Ś_repr_overrideNŚexprr$   ŚnameŚ
parametersśdict[str, Any] | NonerP   ŚNonec                ó2    |j         | _         ||d| _        d S )N)Śparamsr©   )Ś_pyexprr\   )ŚselfrØ   r©   rŖ   s       rV   Ś__init__z_selector_proxy_.__init__<  s%    š |ą Ųš
š 
rW   Śintc                ó:    t          t          | ¦  «        ¦  «        S rS   )ŚhashŚrepr©r°   s    rV   Ś__hash__z_selector_proxy_.__hash__H  s    õ DJJŃŌŠrW   r.   c                ó    t          | ¦  «        rt          ¦   «         | z
  }d| |_        n|                      ¦   «          }|S )zInvert the selector.ś~)rD   r/   r§   Śas_expr)r°   Śinverteds     rV   Ś
__invert__z_selector_proxy_.__invert__M  sD    åtŃŌš 	'Żuut|HŲ&2Ø$ l lHŌ#Š#ąHŲrW   c                ó   t          | d¦  «        s!t          |                      ¦   «         ¦  «        S t          | d¦  «        r| j        S | j        d         | j        d         pi }}ddddd	}||v rP||         }d
                     d| d                     d |                     ¦   «         D ¦   «         ¦  «        ¦  «        S d                     d |                     ¦   «         D ¦   «         ¦  «         	                    d¦  «        }d| d| dS )Nr\   r§   r©   r®   ś&r   ś-r   )ŚandŚorŚsubŚxorz({})ś c              3  ó4   K   | ]}t          |¦  «        V  d S rS   )rµ   )r   Śps     rV   r   z,_selector_proxy_.__repr__.<locals>.<genexpr>`  s(   č č  Š3UŠ3UĄµDø±G“GŠ3UŠ3UŠ3UŠ3UŠ3UŠ3UrW   z, c              3  ó   K   | ]:\  }}|                      d ¦  «        rt          |¦  «        dd         n| d|V  ;dS )Ś*r   é’’’’ś=N)r   rµ   )r   ŚkŚvs      rV   r   z,_selector_proxy_.__repr__.<locals>.<genexpr>b  sg   č č  š 'š 'į1š '(§l¢l°3Ń&7Ō&7ŠIT!WWQrT]]Ąø\ø\ĄAø\ø\š'š 'š 'š 'š 'š 'rW   ś,zcs.r   r   )
r^   rµ   rŗ   r§   r\   Śformatr   Śvaluesrs   Śrstrip)r°   Śselector_namer®   Śset_opsŚopŚ
str_paramss         rV   Ś__repr__z_selector_proxy_.__repr__V  s(   ŻtXŃ&Ō&š 	;ŻŃ'Ō'Š'ŻTŠ+Ń,Ō,š 	;ŲŌ&Š&ą$(¤K°Ō$7ø¼ĄXŌ9NŠ9TŠRT6MŲ!Ø°SĄŠEŠEGŲ Š'Š'Ų]Ō+Ų}} YØ Y Y Y§^¢^Š3UŠ3UĄVĒ]Ā]Į_Ä_Š3UŃ3UŌ3UŃ%UŌ%UŃVŌVŠVą!YYš 'š 'ą &§¢”¤š'ń 'ō 'ń ō ÷ &++š š ;]Š:Š:ØZŠ:Š:Š:Š:rW   Śotherr*   c                ó    d S rS   rT   ©r°   rÖ   s     rV   Ś__add__z_selector_proxy_.__add__h  ó    Ų<?øCrW   r   c                ó    d S rS   rT   rŲ   s     rV   rŁ   z_selector_proxy_.__add__k  ó    Ų+.Ø3rW   rc   c                ó    t          |¦  «        rd}t          |¦  «        |                      ¦   «                              |¦  «        S )Nz=unsupported operand type(s) for op: ('Selector' + 'Selector'))rD   rl   rŗ   rŁ   ©r°   rÖ   rp   s      rV   rŁ   z_selector_proxy_.__add__n  s?    ŻuŃŌš 	1ŲQCŻC..Š ą<<>>×)Ņ)Ø%Ń0Ō0Š0rW   c                ó$    d}t          |¦  «        )Nz9unsupported operand type(s) for op: ('Expr' + 'Selector')©rl   rŽ   s      rV   Ś__radd__z_selector_proxy_.__radd__u  ó    ŲIŻnnŠrW   c                ó    d S rS   rT   rŲ   s     rV   Ś__and__z_selector_proxy_.__and__y  rŚ   rW   c                ó    d S rS   rT   rŲ   s     rV   rä   z_selector_proxy_.__and__|  rÜ   rW   c                ód   t          |¦  «        r(|j                             ¦   «         }t          |¦  «        }t	          |¦  «        rDt          | j                             ¦   «         j                             |¦  «        | |dd¬¦  «        S |                      ¦   «          	                    |¦  «        S )NrŲ   rĄ   ©rŖ   r©   )
r   rj   r   r6   rD   rO   Ś_as_selectorŚ_selector_andrŗ   rä   ©r°   rÖ   Ścolnames      rV   rä   z_selector_proxy_.__and__  s§    ŻUŃŌš 	%Ųj×,Ņ,Ń.Ō.GŻGŃ$Ō$EŻuŃŌš 	1Ż#Ų	×&Ņ&Ń(Ō(Ō-×;Ņ;øEŃBŌBŲ$(°5Š9Š9Ųšń ō š š <<>>×)Ņ)Ø%Ń0Ō0Š0rW   c                óÄ    t          |¦  «        r+|j                             ¦   «         }t          |¦  «        | z  S |                      ¦   «                              |¦  «        S rS   )r   rj   r   r6   rŗ   Ś__rand__rź   s      rV   rķ   z_selector_proxy_.__rand__  sT    ŻUŃŌš 	+Ųj×,Ņ,Ń.Ō.GŻ7Ń#Ō# dŃ*Š*Ų||~~×&Ņ& uŃ-Ō-Š-rW   c                ó    d S rS   rT   rŲ   s     rV   Ś__or__z_selector_proxy_.__or__  s    Ų;>ø3rW   c                ó    d S rS   rT   rŲ   s     rV   rļ   z_selector_proxy_.__or__  s    Ų*-Ø#rW   c                ó`   t          |¦  «        r&t          |j                             ¦   «         ¦  «        }t	          |¦  «        rDt          | j                             ¦   «         j                             |¦  «        | |dd¬¦  «        S |                      ¦   «          	                    |¦  «        S )NrŲ   rĮ   rē   )
r   r6   rj   r   rD   rO   rč   Ś_selector_addrŗ   rļ   rŲ   s     rV   rļ   z_selector_proxy_.__or__  s¢    ŻUŃŌš 	6ŻEJ×2Ņ2Ń4Ō4Ń5Ō5EŻuŃŌš 	0Ż#Ų	×&Ņ&Ń(Ō(Ō-×;Ņ;øEŃBŌBŲ$(°5Š9Š9Ųšń ō š š <<>>×(Ņ(ØŃ/Ō/Š/rW   c                óŗ    t          |¦  «        r&t          |j                             ¦   «         ¦  «        }|                      ¦   «                              |¦  «        S rS   )r   r6   rj   r   rŗ   Ś__ror__rŲ   s     rV   rō   z_selector_proxy_.__ror__¤  sI    ŻUŃŌš 	6ŻEJ×2Ņ2Ń4Ō4Ń5Ō5EŲ||~~×%Ņ% eŃ,Ō,Š,rW   c                ó    d S rS   rT   rŲ   s     rV   Ś__sub__z_selector_proxy_.__sub__©  rŚ   rW   c                ó    d S rS   rT   rŲ   s     rV   rö   z_selector_proxy_.__sub__¬  s    Ų:=ø#rW   c                óö    t          |¦  «        rDt          | j                             ¦   «         j                             |¦  «        | |dd¬¦  «        S |                      ¦   «                              |¦  «        S )NrŲ   rĀ   rē   )rD   rO   rj   rč   Ś_selector_subrŗ   rö   rŲ   s     rV   rö   z_selector_proxy_.__sub__Æ  sw    ŻuŃŌš 	1Ż#Ų	×&Ņ&Ń(Ō(Ō-×;Ņ;øEŃBŌBŲ$(°5Š9Š9Ųšń ō š š <<>>×)Ņ)Ø%Ń0Ō0Š0rW   r   c                ó$    d}t          |¦  «        )Nz9unsupported operand type(s) for op: ('Expr' - 'Selector')rą   rŽ   s      rV   Ś__rsub__z_selector_proxy_.__rsub__¹  rā   rW   c                ó    d S rS   rT   rŲ   s     rV   Ś__xor__z_selector_proxy_.__xor__½  rŚ   rW   c                ó    d S rS   rT   rŲ   s     rV   rż   z_selector_proxy_.__xor__Ą  rÜ   rW   c                ó`   t          |¦  «        r&t          |j                             ¦   «         ¦  «        }t	          |¦  «        rDt          | j                             ¦   «         j                             |¦  «        | |dd¬¦  «        S |                      ¦   «          	                    |¦  «        S )NrŲ   rĆ   rē   )
r   r6   rj   r   rD   rO   rč   Ś_selector_xorrŗ   rż   rŲ   s     rV   rż   z_selector_proxy_.__xor__Ć  s¢    ŻUŃŌš 	6ŻEJ×2Ņ2Ń4Ō4Ń5Ō5EŻuŃŌš 	1Ż#Ų	×&Ņ&Ń(Ō(Ō-×;Ņ;øEŃBŌBŲ$(°5Š9Š9Ųšń ō š š <<>>×)Ņ)Ø%Ń0Ō0Š0rW   c                óŗ    t          |¦  «        r&t          |j                             ¦   «         ¦  «        }|                      ¦   «                              |¦  «        S rS   )r   r6   rj   r   rŗ   Ś__rxor__rŲ   s     rV   r  z_selector_proxy_.__rxor__Ļ  sI    ŻUŃŌš 	6ŻEJ×2Ņ2Ń4Ō4Ń5Ō5EŲ||~~×&Ņ& uŃ-Ō-Š-rW   c                ó4    t          j        | j        ¦  «        S )u  
        Materialize the `selector` as a normal expression.

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

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

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

        >>> df.select(~cs.boolean())
        shape: (3, 2)
        āāāāāāāā¬āāāāāāā
        ā colx ā colz ā
        ā ---  ā ---  ā
        ā str  ā i64  ā
        āāāāāāāāŖāāāāāāā”
        ā aa   ā 1    ā
        ā bb   ā 2    ā
        ā cc   ā 3    ā
        āāāāāāāā“āāāāāāā

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

        >>> df.select(~cs.boolean().as_expr())
        shape: (3, 1)
        āāāāāāāāā
        ā coly  ā
        ā ---   ā
        ā bool  ā
        āāāāāāāāā”
        ā false ā
        ā true  ā
        ā false ā
        āāāāāāāāā
        )r$   Ś_from_pyexprrÆ   r¶   s    rV   rŗ   z_selector_proxy_.as_exprŌ  s    õ^ Ō  ¤Ń.Ō.Š.rW   rS   )rØ   r$   r©   r   rŖ   r«   rP   r¬   )rP   r²   )rP   r.   )rP   r   )rÖ   r*   rP   r*   )rÖ   r   rP   r$   )rÖ   r   rP   rc   )rÖ   r   rP   r   )rP   r$   )Ś__name__Ś
__module__Ś__qualname__Ś__doc__Ś__annotations__r±   r·   r¼   rÕ   r   rŁ   rį   rä   rķ   rļ   rō   rö   rū   rż   r  rŗ   rT   rW   rV   rO   rO   6  sP        Ų0Š0ąŠŠŃŲŠŠŃš -1š	

š 

š 

š 

š 

š š  š  š  š
š š š š;š ;š ;š ;š$ Ų?Š?Š?ń XŲ?ąŲ.Š.Š.ń XŲ.š1š 1š 1š 1šš š š š Ų?Š?Š?ń XŲ?ąŲ.Š.Š.ń XŲ.š1š 1š 1š 1š.š .š .š .š Ų>Š>Š>ń XŲ>ąŲ-Š-Š-ń XŲ-š
0š 
0š 
0š 
0š-š -š -š -š
 Ų?Š?Š?ń XŲ?ąŲ=Š=Š=ń XŲ=š1š 1š 1š 1šš š š š Ų?Š?Š?ń XŲ?ąŲ.Š.Š.ń XŲ.š
1š 
1š 
1š 
1š.š .š .š .š
//š //š //š //š //š //rW   )ŚescaperJ   śstr | Collection[str]r
  r   c               ó\   t          | t          ¦  «        rrt          | ¦  «        n| }n}g }| D ]W}t          |t          ¦  «        r+t          |t          ¦  «        s|                     |¦  «         B|                     |¦  «         Xd                     fd|D ¦   «         ¦  «        }d| dS )zIReturn escaped regex, potentially representing multiple string fragments.r   c              3  ó>   K   | ]}rt          |¦  «        n|V  d S rS   ©r   )r   Śxr
  s     rV   r   z_re_string.<locals>.<genexpr>  s2   ųč č  ŠGŠGø! vŠ4y |||°1ŠGŠGŠGŠGŠGŠGrW   r   r   )r]   r   r   r   rv   rw   r   )rJ   r
  r   ŚstringsŚsts    `   rV   Ś
_re_stringr    sÄ   ų å&#ŃŌš 	HŲ"(Š4YvŃŌŠØfąŲš 	#š 	#BŻ"jŃ)Ō)š #µ*øRÅŃ2EŌ2Eš #ŲrŃ"Ō"Š"Š"ąrŃ"Ō"Š"Š"ŲXXŠGŠGŠGŠGøwŠGŃGŌGŃGŌGŲr999ŠrW   c                 óF    t          t          j        ¦   «         d¬¦  «        S )uz  
    Select all columns.

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

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

    Select all columns, casting them to string:

    >>> df.select(cs.all().cast(pl.String))
    shape: (2, 2)
    āāāāāāāāāāāāāā¬āāāāāāāāāā
    ā dt         ā value   ā
    ā ---        ā ---     ā
    ā str        ā str     ā
    āāāāāāāāāāāāāāŖāāāāāāāāāā”
    ā 1999-12-31 ā 1234500 ā
    ā 2024-01-01 ā 5000555 ā
    āāāāāāāāāāāāāā“āāāāāāāāāā

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

    >>> df.select(cs.all() - cs.numeric())
    shape: (2, 1)
    āāāāāāāāāāāāāā
    ā dt         ā
    ā ---        ā
    ā date       ā
    āāāāāāāāāāāāāā”
    ā 1999-12-31 ā
    ā 2024-01-01 ā
    āāāāāāāāāāāāāā
    r/   ©r©   )rO   ŚFr/   rT   rW   rV   r/   r/     s    õ^ AEGGØ%Š0Ń0Ō0Š0rW   )Śignore_spacesŚ
ascii_onlyr  c               ót    | rdnd}|rdnd}t          t          j        d| | d¦  «        d| |d¬	¦  «        S )
uW  
    Select all columns with alphabetic names (eg: only letters).

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

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

    Examples
    --------
    >>> import polars as pl
    >>> import polars.selectors as cs
    >>> df = pl.DataFrame(
    ...     {
    ...         "no1": [100, 200, 300],
    ...         "cafĆ©": ["espresso", "latte", "mocha"],
    ...         "t or f": [True, False, None],
    ...         "hmm": ["aaa", "bbb", "ccc"],
    ...         "é½åø": ["ę±äŗ¬", "å¤§éŖ", "äŗ¬é½"],
    ...     }
    ... )

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

    >>> df.select(cs.alpha())
    shape: (3, 3)
    āāāāāāāāāāāā¬āāāāāā¬āāāāāāā
    ā cafĆ©     ā hmm ā é½åø ā
    ā ---      ā --- ā ---  ā
    ā str      ā str ā str  ā
    āāāāāāāāāāāāŖāāāāāāŖāāāāāāā”
    ā espresso ā aaa ā ę±äŗ¬ ā
    ā latte    ā bbb ā å¤§éŖ ā
    ā mocha    ā ccc ā äŗ¬é½ ā
    āāāāāāāāāāāā“āāāāāā“āāāāāāā

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

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

    >>> df.select(cs.alpha(ascii_only=True, ignore_spaces=True))
    shape: (3, 2)
    āāāāāāāāāā¬āāāāāā
    ā t or f ā hmm ā
    ā ---    ā --- ā
    ā bool   ā str ā
    āāāāāāāāāāŖāāāāāā”
    ā true   ā aaa ā
    ā false  ā bbb ā
    ā null   ā ccc ā
    āāāāāāāāāā“āāāāāā

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

    >>> df.select(~cs.alpha())
    shape: (3, 2)
    āāāāāāā¬āāāāāāāāā
    ā no1 ā t or f ā
    ā --- ā ---    ā
    ā i64 ā bool   ā
    āāāāāāāŖāāāāāāāāā”
    ā 100 ā true   ā
    ā 200 ā false  ā
    ā 300 ā null   ā
    āāāāāāā“āāāāāāāāā

    >>> df.select(~cs.alpha(ignore_spaces=True))
    shape: (3, 1)
    āāāāāāā
    ā no1 ā
    ā --- ā
    ā i64 ā
    āāāāāāā”
    ā 100 ā
    ā 200 ā
    ā 300 ā
    āāāāāāā
    śa-zA-Zś\p{Alphabetic}rÄ   Ś ś^[ś]+$r0   ©r  r  ©r©   rŖ   ©rO   r  Ścol)r  r  Śre_alphaŚre_spaces       rV   r0   r0   G  se    šL 'Š=yyŠ,=HŲ#Š+ssØHŻŻ	Š*8Š*XŠ*Š*Š*Ń+Ō+ŲŲ",ø}ŠMŠMšń ō š rW   c          	     ó    | rdnd}| rdnd}|rdnd}t          t          j        d| | | d¦  «        d	| |d
¬¦  «        S )uF  
    Select all columns with alphanumeric names (eg: only letters and the digits 0-9).

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

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

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

    Select columns with alphanumeric names:

    >>> df.select(cs.alphanumeric())
    shape: (3, 2)
    āāāāāāāāāāā¬āāāāāāāāāāā
    ā flagged ā 00prefix ā
    ā ---     ā ---      ā
    ā bool    ā str      ā
    āāāāāāāāāāāŖāāāāāāāāāāā”
    ā true    ā 01:aa    ā
    ā false   ā 02:bb    ā
    ā true    ā 03:cc    ā
    āāāāāāāāāāā“āāāāāāāāāāā

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

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

    >>> df.select(~cs.alphanumeric())
    shape: (3, 2)
    āāāāāāāāāāā¬āāāāāāāāāāā
    ā 1st_col ā last col ā
    ā ---     ā ---      ā
    ā i64     ā str      ā
    āāāāāāāāāāāŖāāāāāāāāāāā”
    ā 100     ā x        ā
    ā 200     ā y        ā
    ā 300     ā z        ā
    āāāāāāāāāāā“āāāāāāāāāāā

    >>> df.select(~cs.alphanumeric(ignore_spaces=True))
    shape: (3, 1)
    āāāāāāāāāāā
    ā 1st_col ā
    ā ---     ā
    ā i64     ā
    āāāāāāāāāāā”
    ā 100     ā
    ā 200     ā
    ā 300     ā
    āāāāāāāāāāā
    r  r  z0-9ś\drÄ   r  r  r  r1   r  r  r   )r  r  r"  Śre_digitr#  s        rV   r1   r1   ¶  sx    št 'Š=yyŠ,=HŲ"Š-uuØHŲ#Š+ssØHŻŻ	Š48Š4XŠ4 xŠ4Š4Š4Ń5Ō5ŲŲ",ø}ŠMŠMšń ō š rW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )u¶  
    Select all binary columns.

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

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

    Select binary columns and export as a dict:

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

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

    >>> df.select(~cs.binary()).to_dict(as_series=False)
    {'b': ['world'], 'd': [':)']}
    r2   r  )rO   r  r!  r   rT   rW   rV   r2   r2     s     õB AE„&MM°Š9Ń9Ō9Š9rW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )u)  
    Select all boolean columns.

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

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

    Select and invert boolean columns:

    >>> df.with_columns(is_odd=cs.boolean().not_())
    shape: (4, 3)
    āāāāāāā¬āāāāāāāāā¬āāāāāāāāā
    ā n   ā n_even ā is_odd ā
    ā --- ā ---    ā ---    ā
    ā i64 ā bool   ā bool   ā
    āāāāāāāŖāāāāāāāāāŖāāāāāāāāā”
    ā 1   ā false  ā true   ā
    ā 2   ā true   ā false  ā
    ā 3   ā false  ā true   ā
    ā 4   ā true   ā false  ā
    āāāāāāā“āāāāāāāāā“āāāāāāāāā

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

    >>> df.select(~cs.boolean())
    shape: (4, 1)
    āāāāāāā
    ā n   ā
    ā --- ā
    ā i64 ā
    āāāāāāā”
    ā 1   ā
    ā 2   ā
    ā 3   ā
    ā 4   ā
    āāāāāāā
    r3   r  )rO   r  r!  r   rT   rW   rV   r3   r3   >  s     õn AE„'NN°Š;Ń;Ō;Š;rW   r¢   śUPolarsDataType | PythonDataType | Iterable[PolarsDataType] | Iterable[PythonDataType]c                 óĘ   g }| D ]·}t          |¦  «        st          |t          ¦  «        r|                     |¦  «         <t          |t          ¦  «        rS|D ]O}t          |¦  «        s)t          |t          ¦  «        sd|}t          |¦  «        |                     |¦  «         P¤d|}t          |¦  «        t          t          j        |¦  «        dd|i¬¦  «        S )u“  
    Select all columns matching the given dtypes.

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

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

    Select all columns with date or string dtypes:

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

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

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

    Group by string columns and sum the numeric columns:

    >>> df.group_by(cs.string()).agg(cs.numeric().sum()).sort(by="other")
    shape: (2, 2)
    āāāāāāāāā¬āāāāāāāāāāā
    ā other ā value    ā
    ā ---   ā ---      ā
    ā str   ā i64      ā
    āāāāāāāāāŖāāāāāāāāāāā”
    ā bar   ā 5000555  ā
    ā foo   ā -3265500 ā
    āāāāāāāāā“āāāāāāāāāāā
    zinvalid dtype: r4   r¢   r  )	r   r]   Śtyperw   r   rl   rO   r  r!  )r¢   Ś
all_dtypesŚtpŚtrp   s        rV   r4   r4   x  s   šJ 9;JŲš !š !Ż2ŃŌš 
	!„*ØRµŃ"6Ō"6š 
	!Ų×ŅbŃ!Ō!Š!Š!ŻJŃ'Ō'š 	!Ųš %š %Ż'ØŃ*Ō*š )­jø½DŃ.AŌ.Aš )Ų1ØAŠ1Š1CŻ# C..Š(Ų×!Ņ! !Ń$Ō$Š$Š$š	%š + BŠ*Š*CŻC..Š åŻ	jŃŌ 
øĄ*Š7Mšń ō š rW   Śindicesś#int | range | Sequence[int | range]c                 ó0   g }| D ]r}t          |t          t          f¦  «        r|                     |¦  «         4t          |t          ¦  «        r|                     |¦  «         _d|}t          |¦  «        t          t          j	        | dd| i¬¦  «        S )u  
    Select all columns matching the given indices (or range objects).

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

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

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

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

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

    >>> df.select(cs.by_index(0, 1, 2, -2, -1))
    shape: (1, 5)
    āāāāāāā¬āāāāāā¬āāāāāā¬āāāāāāā¬āāāāāāā
    ā key ā c00 ā c01 ā c98  ā c99  ā
    ā --- ā --- ā --- ā ---  ā ---  ā
    ā str ā f64 ā f64 ā f64  ā f64  ā
    āāāāāāāŖāāāāāāŖāāāāāāŖāāāāāāāŖāāāāāāā”
    ā abc ā 0.0 ā 0.5 ā 49.0 ā 49.5 ā
    āāāāāāā“āāāāāā“āāāāāā“āāāāāāā“āāāāāāā

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

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

    >>> df.select(cs.by_index(0, range(101, 0, -25)))
    shape: (1, 5)
    āāāāāāā¬āāāāāāā¬āāāāāāā¬āāāāāāā¬āāāāāā
    ā key ā c75  ā c50  ā c25  ā c00 ā
    ā --- ā ---  ā ---  ā ---  ā --- ā
    ā str ā f64  ā f64  ā f64  ā f64 ā
    āāāāāāāŖāāāāāāāŖāāāāāāāŖāāāāāāāŖāāāāāā”
    ā abc ā 37.5 ā 25.0 ā 12.5 ā 0.0 ā
    āāāāāāā“āāāāāāā“āāāāāāā“āāāāāāā“āāāāāā

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

    >>> df.select(~cs.by_index(range(1, 100, 2)))
    shape: (1, 51)
    āāāāāāā¬āāāāāā¬āāāāāā¬āāāāāā¬āāāā¬āāāāāāā¬āāāāāāā¬āāāāāāā¬āāāāāāā
    ā key ā c01 ā c03 ā c05 ā ā¦ ā c93  ā c95  ā c97  ā c99  ā
    ā --- ā --- ā --- ā --- ā   ā ---  ā ---  ā ---  ā ---  ā
    ā str ā f64 ā f64 ā f64 ā   ā f64  ā f64  ā f64  ā f64  ā
    āāāāāāāŖāāāāāāŖāāāāāāŖāāāāāāŖāāāāŖāāāāāāāŖāāāāāāāŖāāāāāāāŖāāāāāāā”
    ā abc ā 0.5 ā 1.5 ā 2.5 ā ā¦ ā 46.5 ā 47.5 ā 48.5 ā 49.5 ā
    āāāāāāā“āāāāāā“āāāāāā“āāāāāā“āāāā“āāāāāāā“āāāāāāā“āāāāāāā“āāāāāāā
    zinvalid index value: r5   z*indicesr  )
r]   Śranger   rv   r²   rw   rl   rO   r  Śnth)r/  Śall_indicesŚidxrp   s       rV   r5   r5   Š  s³    šl  KŲš !š !ŻcE„8Š,Ń-Ō-š 	!Ų×ŅsŃ#Ō#Š#Š#ŻSŃ!Ō!š 	!Ų×ŅsŃ#Ō#Š#Š#ą1Ø#Š1Š1CŻC..Š åŻ	{Š *ø*ĄgŠ9Nšń ō š rW   )Śrequire_allr    r6  c                óę   g }|D ]}t          |t          ¦  «        r|                     |¦  «         -t          |t          ¦  «        rD|D ]@}t          |t          ¦  «        sd|}t	          |¦  «        |                     |¦  «         Ad|}t	          |¦  «        d|i}|}| s(dd                     d |D ¦   «         ¦  «         d}| |d<   t          t          j        |¦  «        d|¬	¦  «        S )
uį  
    Select all columns matching the given names.

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

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

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

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

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

    Select columns by name:

    >>> df.select(cs.by_name("foo", "bar"))
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā foo ā bar ā
    ā --- ā --- ā
    ā str ā i64 ā
    āāāāāāāŖāāāāāā”
    ā x   ā 123 ā
    ā y   ā 456 ā
    āāāāāāā“āāāāāā

    Match *any* of the given columns by name:

    >>> df.select(cs.by_name("baz", "moose", "foo", "bear", require_all=False))
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā foo ā baz ā
    ā --- ā --- ā
    ā str ā f64 ā
    āāāāāāāŖāāāāāā”
    ā x   ā 2.0 ā
    ā y   ā 5.5 ā
    āāāāāāā“āāāāāā

    Match all columns *except* for those given:

    >>> df.select(~cs.by_name("foo", "bar"))
    shape: (2, 2)
    āāāāāāā¬āāāāāāāā
    ā baz ā zap   ā
    ā --- ā ---   ā
    ā f64 ā bool  ā
    āāāāāāāŖāāāāāāāā”
    ā 2.0 ā false ā
    ā 5.5 ā true  ā
    āāāāāāā“āāāāāāāā
    zinvalid name: z*namesz^(r   c              3  ó4   K   | ]}t          |¦  «        V  d S rS   r  )r   Śnms     rV   r   zby_name.<locals>.<genexpr>  s(   č č  Š"EŠ"E°R„9ØR”=¤=Š"EŠ"EŠ"EŠ"EŠ"EŠ"ErW   z)$r6  r6   r  )	r]   r   rw   r   rl   r   rO   r  r!  )r6  r    Ś	all_namesr9  Śnrp   Śselector_paramsŚ
match_colss           rV   r6   r6   5  s;   šV IŲš !š !Żb#ŃŌš 
	!Ų×ŅRŃ Ō Š Š ŻJŃ'Ō'š 	!Ųš $š $Ż! !„SŃ)Ō)š )Ų0Ø1Š0Š0CŻ# C..Š(Ų× Ņ  Ń#Ō#Š#Š#š	$š * 2Š)Š)CŻC..Š ą'/°Š&;OŲ"+JŲš 5ŲI#((Š"EŠ"Eø9Š"EŃ"EŌ"EŃEŌEŠIŠIŠI
Ų)4Ń&åŻ	jŃŌŲŲ"šń ō š rW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )ub  
    Select all categorical columns.

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

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

    Select all categorical columns:

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

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

    >>> df.select(~cs.categorical())
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā bar ā baz ā
    ā --- ā --- ā
    ā i64 ā f64 ā
    āāāāāāāŖāāāāāā”
    ā 123 ā 2.0 ā
    ā 456 ā 5.5 ā
    āāāāāāā“āāāāāā
    r7   r  )rO   r  r!  r   rT   rW   rV   r7   r7     s"    õ^ AE„+Ń.Ō.°]ŠCŃCŌCŠCrW   Ś	substringc                 óx    t          | ¦  «        }d| d}t          t          j        |¦  «        dd|i¬¦  «        S )uø  
    Select columns whose names contain the given literal substring(s).

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

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

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

    Select columns that contain the substring 'ba':

    >>> df.select(cs.contains("ba"))
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā bar ā baz ā
    ā --- ā --- ā
    ā i64 ā f64 ā
    āāāāāāāŖāāāāāā”
    ā 123 ā 2.0 ā
    ā 456 ā 5.5 ā
    āāāāāāā“āāāāāā

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

    >>> df.select(cs.contains("ba", "z"))
    shape: (2, 3)
    āāāāāāā¬āāāāāā¬āāāāāāāā
    ā bar ā baz ā zap   ā
    ā --- ā --- ā ---   ā
    ā i64 ā f64 ā bool  ā
    āāāāāāāŖāāāāāāŖāāāāāāāā”
    ā 123 ā 2.0 ā false ā
    ā 456 ā 5.5 ā true  ā
    āāāāāāā“āāāāāā“āāāāāāāā

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

    >>> df.select(~cs.contains("ba"))
    shape: (2, 2)
    āāāāāāā¬āāāāāāāā
    ā foo ā zap   ā
    ā --- ā ---   ā
    ā str ā bool  ā
    āāāāāāāŖāāāāāāāā”
    ā x   ā false ā
    ā y   ā true  ā
    āāāāāāā“āāāāāāāā
    ś^.*ś.*$r8   z
*substringr  ©r  rO   r  r!  )r?  Śescaped_substringŚ
raw_paramss      rV   r8   r8   Ķ  sT    õD # 9Ń-Ō-ŠŲ-Š(Š-Š-Š-JåŻ	jŃŌŲŲ Š"3Š4šń ō š rW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )u  
    Select all date columns.

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

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

    Select all date columns:

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

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

    >>> df.select(~cs.date())
    shape: (2, 2)
    āāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāā
    ā dtm                 ā tm       ā
    ā ---                 ā ---      ā
    ā datetime[Ī¼s]        ā time     ā
    āāāāāāāāāāāāāāāāāāāāāāāŖāāāāāāāāāāā”
    ā 2001-05-07 10:25:00 ā 00:00:00 ā
    ā 2031-12-31 00:30:00 ā 23:59:59 ā
    āāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāā
    r9   r  )rO   r  r!  r   rT   rW   rV   r9   r9     ó     õb AE„$KKØfŠ5Ń5Ō5Š5rW   ©rČ   NŚ	time_unitś&TimeUnit | Collection[TimeUnit] | NoneŚ	time_zoneś9str | timezone | Collection[str | timezone | None] | Nonec                ó6   | g d¢} n't          | t          ¦  «        r| gnt          | ¦  «        } dgn0r.t          t          t          f¦  «        rgnt          ¦  «        fd| D ¦   «         }t	          t          j        |¦  «        d| d¬¦  «        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Śnsc                ó:    g | ]}D ]}t          ||¦  «        S rT   )r   )r   ŚtuŚtzrK  s      rV   ś
<listcomp>zdatetime.<locals>.<listcomp>ą  s0   ų ŠPŠPŠPØBĄiŠPŠPĄx  BŃ'Ō'ŠPŠPŠPŠPrW   r:   )rI  rK  r  )r]   r   Ślistr   rO   r  r!  )rI  rK  Śdatetime_dtypess    ` rV   r:   r:   M  sÅ   ų šN ŠŲ&Š&Š&		å#-Øi½Ń#=Ō#=ŠRYKKÅ4Č	Į?Ä?	ąŠŲF		Ų	š 
å% iµ#µx°ŃAŌAŠVYKKÅtČIĮÄš 	š QŠPŠPŠP°)ŠPŃPŌPOåŻ	oŃŌŲŲ!*øŠCŠCšń ō š rW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )u  
    Select all decimal columns.

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

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

    Select all decimal columns:

    >>> df.select(cs.decimal())
    shape: (2, 2)
    āāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāā
    ā bar          ā baz           ā
    ā ---          ā ---           ā
    ā decimal[*,0] ā decimal[10,5] ā
    āāāāāāāāāāāāāāāāŖāāāāāāāāāāāāāāāā”
    ā 123          ā 2.00050       ā
    ā 456          ā -50.55550     ā
    āāāāāāāāāāāāāāāā“āāāāāāāāāāāāāāāā

    Select all columns *except* the decimal ones:

    >>> df.select(~cs.decimal())
    shape: (2, 1)
    āāāāāāā
    ā foo ā
    ā --- ā
    ā str ā
    āāāāāāā”
    ā x   ā
    ā y   ā
    āāāāāāā
    r;   r  )rO   r  r!  r   rT   rW   rV   r;   r;   é  s     õd AE„'NN°Š;Ń;Ō;Š;rW   c                ó\    | rdnd}t          t          j        d| d¦  «        d¬¦  «        S )u
  
    Select all columns having names consisting only of digits.

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

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

    Select columns with digit names:

    >>> df.select(cs.digit())
    shape: (2, 2)
    āāāāāāāā¬āāāāāāā
    ā 2001 ā 2025 ā
    ā ---  ā ---  ā
    ā i64  ā i64  ā
    āāāāāāāāŖāāāāāāā”
    ā -25  ā 75   ā
    ā 95   ā -15  ā
    āāāāāāāā“āāāāāāā

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

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

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

    >>> df = pl.DataFrame({"ą„§ą„Æą„Æą„Æ": [1999], "ą„Øą„¦ą„­ą„­": [2077], "3000": [3000]})
    >>> df.select(cs.digit())
    shape: (1, 3)
    āāāāāāāā¬āāāāāāā¬āāāāāāā
    ā ą„§ą„Æą„Æą„Æ ā ą„Øą„¦ą„­ą„­ ā 3000 ā
    ā ---  ā ---  ā ---  ā
    ā i64  ā i64  ā i64  ā
    āāāāāāāāŖāāāāāāāŖāāāāāāā”
    ā 1999 ā 2077 ā 3000 ā
    āāāāāāāā“āāāāāāā“āāāāāāā

    >>> df.select(cs.digit(ascii_only=True))
    shape: (1, 1)
    āāāāāāāā
    ā 3000 ā
    ā ---  ā
    ā i64  ā
    āāāāāāāā”
    ā 3000 ā
    āāāāāāāā
    z[0-9]r%  r   z+$r<   r  r   )r  r&  s     rV   r<   r<     s<    šn &Š0xxØ5HŻAEŠ"3 xŠ"3Š"3Š"3Ń4Ō4ø7ŠCŃCŌCŠCrW   c                óĀ    | g d¢} n't          | t          ¦  «        r| gnt          | ¦  «        } d | D ¦   «         }t          t	          j        |¦  «        dd| i¬¦  «        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 ā
    āāāāāāāāāāāāāā
    NrN  c                ó,    g | ]}t          |¦  «        S rT   )r   )r   rS  s     rV   rU  zduration.<locals>.<listcomp>ą  s    Š8Š8Š8Øx ||Š8Š8Š8rW   r=   rI  r  )r]   r   rV  rO   r  r!  )rI  Śduration_dtypess     rV   r=   r=   y  sz    šD ŠŲ&Š&Š&		å#-Øi½Ń#=Ō#=ŠRYKKÅ4Č	Į?Ä?	ą8Š8ØiŠ8Ń8Ō8OŻŻ	oŃŌŲŲ Š+šń ō š rW   Śsuffixc                 óx    t          | ¦  «        }d| d}t          t          j        |¦  «        dd|i¬¦  «        S )u/  
    Select columns that end with the given substring(s).

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

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

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

    Select columns that end with the substring 'z':

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

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

    >>> df.select(cs.ends_with("z", "r"))
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā bar ā baz ā
    ā --- ā --- ā
    ā i64 ā f64 ā
    āāāāāāāŖāāāāāā”
    ā 123 ā 2.0 ā
    ā 456 ā 5.5 ā
    āāāāāāā“āāāāāā

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

    >>> df.select(~cs.ends_with("z"))
    shape: (2, 3)
    āāāāāāā¬āāāāāā¬āāāāāāāā
    ā foo ā bar ā zap   ā
    ā --- ā --- ā ---   ā
    ā str ā i64 ā bool  ā
    āāāāāāāŖāāāāāāŖāāāāāāāā”
    ā x   ā 123 ā false ā
    ā y   ā 456 ā true  ā
    āāāāāāā“āāāāāā“āāāāāāāā
    rA  r   r>   z*suffixr  rC  )r]  Śescaped_suffixrE  s      rV   r>   r>   č  sQ    õD   Ń'Ō'NŲ(~Š(Š(Š(JåŻ	jŃŌŲŲ~Š.šń ō š rW   Ścolumnsścstr | PolarsDataType | SelectorType | Expr | Collection[str | PolarsDataType | SelectorType | Expr]Śmore_columnsś*str | PolarsDataType | SelectorType | Exprc                ó    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`  rb  s     rV   r?   r?   4  s    õ@ ! Š8Ø<Š8Š8Š8Š8Š8rW   c                 óF    t          t          j        ¦   «         d¬¦  «        S )ub  
    Select the first column in the current scope.

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

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

    Select the first column:

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

    Select everything  *except* for the first column:

    >>> df.select(~cs.first())
    shape: (2, 3)
    āāāāāāā¬āāāāāā¬āāāāāā
    ā bar ā baz ā zap ā
    ā --- ā --- ā --- ā
    ā i64 ā f64 ā i64 ā
    āāāāāāāŖāāāāāāŖāāāāāā”
    ā 123 ā 2.0 ā 0   ā
    ā 456 ā 5.5 ā 1   ā
    āāāāāāā“āāāāāā“āāāāāā
    rA   r  )rO   r  rA   rT   rW   rV   rA   rA   w  s    õ^ AGIIØGŠ4Ń4Ō4Š4rW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )u  
    Select all float columns.

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

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

    Select all float columns:

    >>> df.select(cs.float())
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā baz ā zap ā
    ā --- ā --- ā
    ā f32 ā f64 ā
    āāāāāāāŖāāāāāā”
    ā 2.0 ā 0.0 ā
    ā 5.5 ā 1.0 ā
    āāāāāāā“āāāāāā

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

    >>> df.select(~cs.float())
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā foo ā bar ā
    ā --- ā --- ā
    ā str ā i64 ā
    āāāāāāāŖāāāāāā”
    ā x   ā 123 ā
    ā y   ā 456 ā
    āāāāāāā“āāāāāā
    rB   r  )rO   r  r!  r   rT   rW   rV   rB   rB   ©  s"    õd AE„,Ń/Ō/°gŠ>Ń>Ō>Š>rW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )uō  
    Select all integer columns.

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

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

    Select all integer columns:

    >>> df.select(cs.integer())
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā bar ā zap ā
    ā --- ā --- ā
    ā i64 ā i64 ā
    āāāāāāāŖāāāāāā”
    ā 123 ā 0   ā
    ā 456 ā 1   ā
    āāāāāāā“āāāāāā

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

    >>> df.select(~cs.integer())
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā foo ā baz ā
    ā --- ā --- ā
    ā str ā f64 ā
    āāāāāāāŖāāāāāā”
    ā x   ā 2.0 ā
    ā y   ā 5.5 ā
    āāāāāāā“āāāāāā
    rC   r  )rO   r  r!  r   rT   rW   rV   rC   rC   Ž  s"    õd AE„.Ń1Ō1ø	ŠBŃBŌBŠBrW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )u1  
    Select all signed integer columns.

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

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

    Select all signed integer columns:

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

    >>> df.select(~cs.signed_integer())
    shape: (2, 3)
    āāāāāāāā¬āāāāāāā¬āāāāāā
    ā bar  ā baz  ā zap ā
    ā ---  ā ---  ā --- ā
    ā u32  ā u64  ā str ā
    āāāāāāāāŖāāāāāāāŖāāāāāā”
    ā 3456 ā 7654 ā ab  ā
    ā 6789 ā 4321 ā cd  ā
    āāāāāāāā“āāāāāāā“āāāāāā

    Select all integer columns (both signed and unsigned):

    >>> df.select(cs.integer())
    shape: (2, 3)
    āāāāāāāā¬āāāāāāā¬āāāāāāā
    ā foo  ā bar  ā baz  ā
    ā ---  ā ---  ā ---  ā
    ā i64  ā u32  ā u64  ā
    āāāāāāāāŖāāāāāāāŖāāāāāāā”
    ā -123 ā 3456 ā 7654 ā
    ā -456 ā 6789 ā 4321 ā
    āāāāāāāā“āāāāāāā“āāāāāāā
    rH   r  )rO   r  r!  r!   rT   rW   rV   rH   rH     s$    õ| AEÕ"7Ń8Ō8Š?OŠPŃPŌPŠPrW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )u|  
    Select all unsigned integer columns.

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

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

    Select all unsigned integer columns:

    >>> df.select(cs.unsigned_integer())
    shape: (2, 2)
    āāāāāāāā¬āāāāāāā
    ā bar  ā baz  ā
    ā ---  ā ---  ā
    ā u32  ā u64  ā
    āāāāāāāāŖāāāāāāā”
    ā 3456 ā 7654 ā
    ā 6789 ā 4321 ā
    āāāāāāāā“āāāāāāā

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

    >>> df.select(~cs.unsigned_integer())
    shape: (2, 2)
    āāāāāāāā¬āāāāāā
    ā foo  ā zap ā
    ā ---  ā --- ā
    ā i64  ā str ā
    āāāāāāāāŖāāāāāā”
    ā -123 ā ab  ā
    ā -456 ā cd  ā
    āāāāāāāā“āāāāāā

    Select all integer columns (both signed and unsigned):

    >>> df.select(cs.integer())
    shape: (2, 3)
    āāāāāāāā¬āāāāāāā¬āāāāāāā
    ā foo  ā bar  ā baz  ā
    ā ---  ā ---  ā ---  ā
    ā i64  ā u32  ā u64  ā
    āāāāāāāāŖāāāāāāāŖāāāāāāā”
    ā -123 ā 3456 ā 7654 ā
    ā -456 ā 6789 ā 4321 ā
    āāāāāāāā“āāāāāāā“āāāāāāā
    rM   r  )rO   r  r!  r#   rT   rW   rV   rM   rM   T  s$    õ@ AEÕ"9Ń:Ō:ŠASŠTŃTŌTŠTrW   c                 óF    t          t          j        ¦   «         d¬¦  «        S )u_  
    Select the last column in the current scope.

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

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

    Select the last column:

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

    Select everything  *except* for the last column:

    >>> df.select(~cs.last())
    shape: (2, 3)
    āāāāāāā¬āāāāāā¬āāāāāā
    ā foo ā bar ā baz ā
    ā --- ā --- ā --- ā
    ā str ā i64 ā f64 ā
    āāāāāāāŖāāāāāāŖāāāāāā”
    ā x   ā 123 ā 2.0 ā
    ā y   ā 456 ā 5.5 ā
    āāāāāāā“āāāāāā“āāāāāā
    rE   r  )rO   r  rE   rT   rW   rV   rE   rE     s    õ^ AFHHØ6Š2Ń2Ō2Š2rW   Śpatternc                óh   | dk    rt          ¦   «         S |                      d¦  «        r| dd         } n|                      d¦  «        r
| dd         } |                      d¦  «        sdnd}|                      d¦  «        sd	nd}| |  | }t          t	          j        |¦  «        d
d| i¬¦  «        S )u÷  
    Select all columns that match the given regex pattern.

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

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

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

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

    >>> df.select(cs.matches("[^z]a"))
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā bar ā baz ā
    ā --- ā --- ā
    ā i64 ā f64 ā
    āāāāāāāŖāāāāāā”
    ā 123 ā 2.0 ā
    ā 456 ā 5.5 ā
    āāāāāāā“āāāāāā

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

    >>> df.select(~cs.matches(r"(?i)R|z$"))
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā foo ā zap ā
    ā --- ā --- ā
    ā str ā i64 ā
    āāāāāāāŖāāāāāā”
    ā x   ā 0   ā
    ā y   ā 1   ā
    āāāāāāā“āāāāāā
    z.*é   Néž’’’r   rA  r  r   rB  rF   rk  r  )r/   r   r   rO   r  r!  )rk  ŚpfxŚsfxrE  s       rV   rF   rF   É  sŪ    šl $Żuuą×ŅdŃ#Ō#š 	#ŲabbkGGŲ×ŅdŃ#Ō#š 	#ŲcrclGą"×-Ņ-ØcŃ2Ō2Š:eeøŲ"×+Ņ+ØCŃ0Ō0Š8ee°bŲŠ+WŠ+ cŠ+Š+
åŻE*ŃŌŲŲ! 7Š+š
ń 
ō 
š 	
rW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )uF  
    Select all numeric columns.

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

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

    Match all numeric columns:

    >>> df.select(cs.numeric())
    shape: (2, 3)
    āāāāāāā¬āāāāāā¬āāāāāā
    ā bar ā baz ā zap ā
    ā --- ā --- ā --- ā
    ā i16 ā f32 ā u8  ā
    āāāāāāāŖāāāāāāŖāāāāāā”
    ā 123 ā 2.0 ā 0   ā
    ā 456 ā 5.5 ā 0   ā
    āāāāāāā“āāāāāā“āāāāāā

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

    >>> df.select(~cs.numeric())
    shape: (2, 1)
    āāāāāāā
    ā foo ā
    ā --- ā
    ā str ā
    āāāāāāā”
    ā x   ā
    ā y   ā
    āāāāāāā
    rG   r  )rO   r  r!  r    rT   rW   rV   rG   rG   	  s"    õf AE„.Ń1Ō1ø	ŠBŃBŌBŠBrW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )u£	  
    Select all object columns.

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

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

    Select object columns and export as a dict:

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

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

    >>> df.select(~cs.object())  # doctest: +IGNORE_RESULT
    {
        "idx": [0, 1],
        "uuid_str": [
            "acab9fea-c05d-4b91-b639-418004a63f33",
            "28c65415-8b7d-4857-a4ce-300dca14b12b",
        ],
    }
    Śobjectr  )rO   r  r!  r   rT   rW   rV   rs  rs  H	  s     õj AE„&MM°Š9Ń9Ō9Š9rW   Śprefixc                 óx    t          | ¦  «        }d| d}t          t          j        |¦  «        dd| i¬¦  «        S )uL  
    Select columns that start with the given substring(s).

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

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

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

    Match columns starting with a 'b':

    >>> df.select(cs.starts_with("b"))
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā bar ā baz ā
    ā --- ā --- ā
    ā f64 ā i64 ā
    āāāāāāāŖāāāāāā”
    ā 3.0 ā 5   ā
    ā 4.0 ā 6   ā
    āāāāāāā“āāāāāā

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

    >>> df.select(cs.starts_with("b", "z"))
    shape: (2, 3)
    āāāāāāā¬āāāāāā¬āāāāāā
    ā bar ā baz ā zap ā
    ā --- ā --- ā --- ā
    ā f64 ā i64 ā i64 ā
    āāāāāāāŖāāāāāāŖāāāāāā”
    ā 3.0 ā 5   ā 7   ā
    ā 4.0 ā 6   ā 8   ā
    āāāāāāā“āāāāāā“āāāāāā

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

    >>> df.select(~cs.starts_with("b"))
    shape: (2, 2)
    āāāāāāā¬āāāāāā
    ā foo ā zap ā
    ā --- ā --- ā
    ā f64 ā i64 ā
    āāāāāāāŖāāāāāā”
    ā 1.0 ā 7   ā
    ā 2.0 ā 8   ā
    āāāāāāā“āāāāāā
    r   rB  rI   z*prefixr  rC  )rt  Śescaped_prefixrE  s      rV   rI   rI   	  sQ    õD   Ń'Ō'NŲ(^Š(Š(Š(JåŻ	jŃŌŲŲvŠ&šń ō š rW   )Śinclude_categoricalrw  c                ó    t           g}| r|                     t          ¦  «         t          t	          j        |¦  «        dd| i¬¦  «        S )un  
    Select all String (and, optionally, Categorical) string columns.

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

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

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

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

    Group by all string *and* categorical columns:

    >>> df.group_by(cs.string(include_categorical=True)).agg(cs.numeric().sum()).sort(
    ...     by=cs.string(include_categorical=True)
    ... )
    shape: (3, 4)
    āāāāāāā¬āāāāāā¬āāāāāā¬āāāāāāā
    ā w   ā z   ā x   ā y    ā
    ā --- ā --- ā --- ā ---  ā
    ā str ā cat ā i64 ā f64  ā
    āāāāāāāŖāāāāāāŖāāāāāāŖāāāāāāā”
    ā xx  ā a   ā 2   ā 4.0  ā
    ā xx  ā b   ā -2  ā -2.0 ā
    ā yy  ā b   ā 6   ā 7.0  ā
    āāāāāāā“āāāāāā“āāāāāā“āāāāāāā
    rJ   rw  r  )r   rw   r   rO   r  r!  )rw  Śstring_dtypess     rV   rJ   rJ   Ģ	  sX    õj ,2Ø(MŲš *Ų×Ņ[Ń)Ō)Š)åŻ	mŃŌŲŲ)Š+>Š?šń ō š rW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )u]  
    Select all temporal columns.

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

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

    Match all temporal columns:

    >>> df.select(cs.temporal())
    shape: (2, 2)
    āāāāāāāāāāāāāā¬āāāāāāāāāāā
    ā dt         ā tm       ā
    ā ---        ā ---      ā
    ā date       ā time     ā
    āāāāāāāāāāāāāāŖāāāāāāāāāāā”
    ā 2021-01-01 ā 12:00:00 ā
    ā 2021-01-02 ā 20:30:45 ā
    āāāāāāāāāāāāāā“āāāāāāāāāāā

    Match all temporal columns *except* for time columns:

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

    Match all columns *except* for temporal columns:

    >>> df.select(~cs.temporal())
    shape: (2, 1)
    āāāāāāāāāā
    ā value  ā
    ā ---    ā
    ā f64    ā
    āāāāāāāāāā”
    ā 1.2345 ā
    ā 2.3456 ā
    āāāāāāāāāā
    rK   r  )rO   r  r!  r"   rT   rW   rV   rK   rK   
  s"    õ~ AE„/Ń2Ō2øŠDŃDŌDŠDrW   c                 óR    t          t          j        t          ¦  «        d¬¦  «        S )u  
    Select all time columns.

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

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

    Select all time columns:

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

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

    >>> df.select(~cs.time())
    shape: (2, 2)
    āāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāā
    ā dtm                 ā dt         ā
    ā ---                 ā ---        ā
    ā datetime[Ī¼s]        ā date       ā
    āāāāāāāāāāāāāāāāāāāāāāāŖāāāāāāāāāāāāā”
    ā 2001-05-07 10:25:00 ā 1999-12-31 ā
    ā 2031-12-31 00:30:00 ā 2024-08-09 ā
    āāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāā
    rL   r  )rO   r  r!  r   rT   rW   rV   rL   rL   N
  rG  rW   )rN   rO   rP   rQ   )rN   r   rP   rX   )rN   r   rP   rZ   )r`   ra   rb   rc   r_   rZ   rP   rd   )rq   rr   rs   r   rP   rt   )r~   r&   r   r   r   rZ   r   rZ   r}   rZ   rP   r   )rs   r   r   r   rP   r*   )rJ   r  r
  rZ   rP   r   )rP   r*   )F)r  rZ   r  rZ   rP   r*   )r¢   r)  rP   r*   )r/  r0  rP   r*   )r    r  r6  rZ   rP   r*   )r?  r   rP   r*   )NrH  )rI  rJ  rK  rL  rP   r*   )r  rZ   rP   r*   rS   )rI  rJ  rP   r*   )r]  r   rP   r*   )r`  ra  rb  rc  rP   r*   )rk  r   rP   r*   )rt  r   rP   r*   )rw  rZ   rP   r*   )`Ś
__future__r   Ścollections.abcr   r   r   r:   r   Ś	functoolsr   Śoperatorr	   Śtypingr
   r   r   r   r   Śpolarsr   r  Śpolars._utils.parse.exprr   Śpolars._utils.variousr   r   Śpolars.datatypesr   r   r   r   r   r   r   r   r   r   r   Śpolars.datatypes.groupr   r   r    r!   r"   r#   Śpolars.exprr$   Śsysr%   r&   r'   Śpolars._typingr(   r)   r*   r+   Śversion_infor.   Śtyping_extensionsŚ__all__rD   r@   r|   r   r„   rO   r  r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r;   r<   r=   r>   r?   rA   rB   rC   rH   rM   rE   rF   rG   rs  rI   rJ   rK   rL   rT   rW   rV   ś<module>r     sŚ  šŲ "Š "Š "Š "Š "Š "ą 9Š 9Š 9Š 9Š 9Š 9Š 9Š 9Š 9Š 9Ų Š Š Š Š Š Ų Š Š Š Š Š Ų Š Š Š Š Š šš š š š š š š š š š š š š š "Š !Š !Š !Š !Š !Ų >Š >Š >Š >Š >Š >Ų 6Š 6Š 6Š 6Š 6Š 6Š 6Š 6šš š š š š š š š š š š š š š š š š š š š š š š š š šš š š š š š š š š š š š š š š š Š Š Š Š Š ąš 
+ŲJJJŲ(Š(Š(Š(Š(Š(ą+Š+Š+Š+Š+Š+Š+Š+ŲUŠUŠUŠUŠUŠUŠUŠUŠUŠUŠUŠUą
Ō7Ņ"Š"ŲŠŠŠŠŠŠą*Š*Š*Š*Š*Š*š š  š  šF 
Ų <Š <Š <ń 
Ų <š 
Ų 0Š 0Š 0ń 
Ų 0šHš Hš Hš Hš. š	L;š L;š L;š L;š L;š L;šb š  š  š  šR šš š š š š š23!š 3!š 3!š 3!šlM/š M/š M/š M/š M/tń M/ō M/š M/š` AEš š š š š š š/1š /1š /1š /1šdløUš lš lš lš lš lš lš` šaš  šaš aš aš aš aš ašH!:š !:š !:š !:šH7<š 7<š 7<š 7<štUš Uš Uš Ušpbš bš bš bšJ @Dš cš cš cš cš cš cšL/Dš /Dš /Dš /DšdIš Iš Iš IšX16š 16š 16š 16šj 9=šNšYš Yš Yš Yš Yšx2<š 2<š 2<š 2<šjXDš XDš XDš XDš XDšx 9=šlš lš lš lš lš^Iš Iš Iš IšX@9š @9š @9š @9šF/5š /5š /5š /5šd2?š 2?š 2?š 2?šj2Cš 2Cš 2Cš 2Cšj>Qš >Qš >Qš >QšB@Uš @Uš @Uš @UšF/3š /3š /3š /3šdF
š F
š F
š F
šR3Cš 3Cš 3Cš 3Cšl5:š 5:š 5:š 5:špIš Iš Iš IšX +0š =š =š =š =š =š =š@?Eš ?Eš ?Eš ?EšD16š 16š 16š 16š 16š 16rW   