
    h                       % S SK Jr  S SKrS SKrS SKJr  S SKJr  S SKJ	r	J
r
JrJr  S SKJr  S SKJr  S SKJrJrJr  S S	KJr  S S
KJr  S SKJr  \R6                  " \5         S SKJrJrJ r   SSS5        \	(       a1  S SKJ!r!  S SK"J#r#J$r$  S SKJ%r%  \RL                  S:  a  S SKJ'r'  OS SK(J'r'  \RL                  S:  a  SS jr)OSS jr)\\*\4   r+\\\\4   r,S\-S'   S/r.SS jr/ " S S\+5      r0g! , (       d  f       N= f)    )annotationsN)OrderedDict)Mapping)TYPE_CHECKINGLiteralUnionoverload)PythonDataType)unstable)DataTypeDataTypeClassis_polars_dtype)parse_into_dtype)DuplicateError)CompatLevel)&init_polars_schema_from_arrow_c_schema'polars_schema_field_from_arrow_c_schemapolars_schema_to_pycapsule)Iterable	DataFrame	LazyFrame)ArrowSchemaExportable)   
   )	TypeAliasc                ,    [        U R                  5      $ N)bool__annotations__tps    G/home/james-whalen/.local/lib/python3.13/site-packages/polars/schema.py_required_init_argsr$   $   s     B&&''    c                     SU R                   ;   $ )N__init__)__dict__r!   s    r#   r$   r$   *   s     R[[((r%   r   SchemaInitDataTypeSchemac                    [        U [        5      (       dR  U R                  5       (       d%  U R                  5       (       d  [	        U 5      (       a  SU < 3n[        U5      eU " 5       n U $ )Nz%dtypes must be fully-specified, got: )
isinstancer   	is_nested
is_decimalr$   	TypeError)r"   msgs     r#   _check_dtyper1   6   sQ    b(##<<>>R]]__0CB0G0G9"@CC. TIr%   c                     ^  \ rS rSrSr SSS.     SU 4S jjjjrSS jrSS jr      SU 4S jjr\	" 5       SS	 j5       r
SS
 jrSS jr\SS j5       r\SS.SS jj5       rSS.SS jjrSS jrSS jrSrU =r$ ) r*   @   a  
Ordered mapping of column names to their data type.

Parameters
----------
schema
    The schema definition given by column names and their associated
    Polars data type. Accepts a mapping, or an iterable of tuples, or any
    object implementing the  `__arrow_c_schema__` PyCapsule interface
    (e.g. pyarrow schemas).

Examples
--------
Define a schema by passing instantiated data types.

>>> schema = pl.Schema(
...     {
...         "foo": pl.String(),
...         "bar": pl.Duration("us"),
...         "baz": pl.Array(pl.Int8, 4),
...     }
... )
>>> schema
Schema({'foo': String, 'bar': Duration(time_unit='us'), 'baz': Array(Int8, shape=(4,))})

Access the data type associated with a specific column name.

>>> schema["baz"]
Array(Int8, shape=(4,))

Access various schema properties using the `names`, `dtypes`, and `len` methods.

>>> schema.names()
['foo', 'bar', 'baz']
>>> schema.dtypes()
[String, Duration(time_unit='us'), Array(Int8, shape=(4,))]
>>> schema.len()
3

Import a pyarrow schema.

>>> import pyarrow as pa
>>> pl.Schema(pa.schema([pa.field("x", pa.int32())]))
Schema({'x': Int32})

Export a schema to pyarrow.

>>> pa.schema(pl.Schema({"x": pl.Int32}))
x: int32
T)check_dtypesc                  > [        US5      (       a!  [        U[        5      (       d  [        X5        g [        U[        5      (       a  UR                  5       O
U=(       d    SnU H  n[        US5      (       a   [        U[        5      (       d  [        U5      OUu  pVXP;   a  SU S3n[        U5      eU(       d  [        TU ])  XV5        Mf  [        U5      (       a  [        TU ])  U[        U5      5        M  X`U'   M     g )N__arrow_c_schema__ z7iterable passed to pl.Schema contained duplicate name '')hasattrr,   r*   r   r   itemsr   r   r   super__setitem__r   r1   )	selfschemar4   inputvnamer"   r0   	__class__s	           r#   r'   Schema.__init__t   s     6/00FF9S9S24@",VW"="=FLbA 1233Jq(<S<S 8: D |OPTvUVW$S))#D- $$#D,r*:;T
! r%   c                   [        U[        5      (       d  g[        U 5      [        U5      :w  a  g[        U R	                  5       UR	                  5       5       H'  u  u  p#u  pEX$:w  d  UR                  U5      (       a  M'    g   g)NFT)r,   r   lenzipr:   is_)r=   othernm1tp1nm2tp2s         r#   __eq__Schema.__eq__   se    %))t9E
"&)$**,&F"JS
z 'G r%   c                .    U R                  U5      (       + $ r   )rM   )r=   rH   s     r#   __ne__Schema.__ne__   s    ;;u%%%r%   c                L   > [        [        U5      5      n[        TU ]  X5        g r   )r1   r   r;   r<   )r=   rA   dtyperB   s      r#   r<   Schema.__setitem__   s"     -e45D(r%   c                T    [        U [        R                  " 5       R                  5      $ )z
Export a Schema via the Arrow PyCapsule Interface.

https://arrow.apache.org/docs/dev/format/CDataInterface/PyCapsuleInterface.html
)r   r   newest_versionr=   s    r#   r6   Schema.__arrow_c_schema__   s      *$0B0B0D0M0MNNr%   c                4    [        U R                  5       5      $ )z
Get the column names of the schema.

Examples
--------
>>> s = pl.Schema({"x": pl.Float64(), "y": pl.Datetime(time_zone="UTC")})
>>> s.names()
['x', 'y']
)listkeysrX   s    r#   namesSchema.names   s     DIIK  r%   c                4    [        U R                  5       5      $ )z
Get the data types of the schema.

Examples
--------
>>> s = pl.Schema({"x": pl.UInt8(), "y": pl.List(pl.UInt8)})
>>> s.dtypes()
[UInt8, List(UInt8)]
)r[   valuesrX   s    r#   dtypesSchema.dtypes   s     DKKM""r%   c                   g r   r7   r=   eagers     r#   to_frameSchema.to_frame   s    ?Br%   .)re   c                   g r   r7   rd   s     r#   rf   rg      s    DGr%   c               8    SSK JnJn  U(       a  U" U S9$ U" U S9$ )u  
Create an empty DataFrame (or LazyFrame) from this Schema.

Parameters
----------
eager
    If True, create a DataFrame; otherwise, create a LazyFrame.

Examples
--------
>>> s = pl.Schema({"x": pl.Int32(), "y": pl.String()})
>>> s.to_frame()
shape: (0, 2)
┌─────┬─────┐
│ x   ┆ y   │
│ --- ┆ --- │
│ i32 ┆ str │
╞═════╪═════╡
└─────┴─────┘
>>> s.to_frame(eager=False)  # doctest: +IGNORE_RESULT
<LazyFrame at 0x11BC0AD80>
r   r   )r>   )polarsr   r   )r=   re   r   r   s       r#   rf   rg      s    . 	0).y%JIT4JJr%   c                    [        U 5      $ )z
Get the number of schema entries.

Examples
--------
>>> s = pl.Schema({"x": pl.Int32(), "y": pl.List(pl.String)})
>>> s.len()
2
>>> len(s)
2
)rE   rX   s    r#   rE   
Schema.len   s     4yr%   c                t    U R                  5        VVs0 s H  u  pXR                  5       _M     snn$ s  snnf )a4  
Return a dictionary of column names and Python types.

Examples
--------
>>> s = pl.Schema(
...     {
...         "x": pl.Int8(),
...         "y": pl.String(),
...         "z": pl.Duration("us"),
...     }
... )
>>> s.to_python()
{'x': <class 'int'>, 'y':  <class 'str'>, 'z': <class 'datetime.timedelta'>}
)r:   	to_python)r=   rA   r"   s      r#   rn   Schema.to_python   s-      6:ZZ\B\lln$\BBBs   4r7   r   )r>   zMapping[str, SchemaInitDataType] | Iterable[tuple[str, SchemaInitDataType] | ArrowSchemaExportable] | ArrowSchemaExportable | Noner4   r   returnNone)rH   objectrp   r   )rA   strrS   z)DataType | DataTypeClass | PythonDataTyperp   rq   )rp   rr   )rp   z	list[str])rp   zlist[DataType])re   zLiteral[False]rp   r   )re   zLiteral[True]rp   r   )re   r   rp   zDataFrame | LazyFrame)rp   int)rp   zdict[str, type])__name__
__module____qualname____firstlineno____doc__r'   rM   rP   r<   r   r6   r]   ra   r	   rf   rE   rn   __static_attributes____classcell__)rB   s   @r#   r*   r*   @   s    1t    "        
     D&)) I)	) ZO O
!
# B B14G G(, K6C Cr%   )r"   r   rp   r   )r"   zDataType | DataTypeClassrp   r   )1
__future__r   
contextlibsyscollectionsr   collections.abcr   typingr   r   r   r	   polars._typingr
   polars._utils.unstabler   polars.datatypesr   r   r   polars.datatypes._parser   polars.exceptionsr   polars.interchange.protocolr   suppressImportErrorpolars._plrr   r   r   r   rj   r   r   r   version_infor   typing_extensionsr$   rs   
BaseSchemar)   r    __all__r1   r*   r7   r%   r#   <module>r      s    "  
 # # : : ) + E E 4 , 3%  & (+4
7"$/w() h'
 %h~&M N I N*ICZ ICa &%s   "C00
C>