Ë
    ¿AHjX«  ã                  óD  — d dl mZ d dlZd dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZmZ d dlmZ d dlmZ d dl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 d dl m!Z!m"Z"m#Z#m$Z$ d dl%m&Z&  ejN                  e(«      5  d dl)m*Z+ ddd«       erd dlm,Z, d dlm-Z-m.Z.m/Z/m0Z0 d dlm1Z1m2Z2m3Z3 	 	 	 	 	 	 	 	 d!d„Z4dddddœ	 	 	 	 	 	 	 	 	 	 	 d"d„Z5dddœ	 	 	 	 	 	 	 d#d„Z6 e«       ddœ	 	 	 	 	 	 	 d$d„«       Z7dddœ	 	 	 	 	 	 	 	 	 d%d„Z8ddddœ	 	 	 	 	 	 	 	 	 	 	 d&d „Z9y# 1 sw Y   Œ•xY w)'é    )ÚannotationsN)Ú	GeneratorÚIteratorÚSequence)Úreduce)Úchain)ÚTYPE_CHECKINGÚget_args)Ú	functions)ÚConcatMethod)Úissue_deprecation_warning)Úreduce_balanced)Úunstable)Úis_non_empty_sequence_ofÚordered_uniqueÚqualified_type_name)Úwrap_dfÚ	wrap_exprÚwrap_ldfÚwrap_s)ÚInvalidOperationError)ÚIterable)Ú	DataFrameÚExprÚ	LazyFrameÚSeries)Ú	FrameTypeÚJoinStrategyÚ
PolarsTypec               óŽ   — |dk(  r+|€t        d| › dd¬«       y|du rt        d| › d	d¬«       yy|dk(  r|d
}t        |«      ‚|S )z1Normalize deprecated horizontal concat arguments.Ú
horizontalz0the default behavior of `how='horizontal'` for `zˆ` is deprecated and will require equal heights in the next breaking release. Use `how='horizontal_extend'` to keep the current behavior.z1.42.1)ÚversionÚhorizontal_extendFzthe `strict` parameter for `z7` is deprecated. Use `how='horizontal_extend'` instead.z6`strict` cannot be used with `how='horizontal_extend'`)r   Ú
ValueError)Úfunction_nameÚhowÚstrictÚmsgs       úN/root/tools/cai/cai_env/lib/python3.12/site-packages/polars/functions/eager.pyÚ_normalize_horizontal_concatr*   !   s„   € ð ˆlÒØˆ>Ü%ØBÀ=À/ð RNð Nð !õð 'Øu‰_Ü%Ø.¨}¨oð >9ð 9à õð
 'àà
Ð!Ò! fÐ&8ØFˆÜ˜‹oÐà€Jó    ÚverticalFT)r&   ÚrechunkÚparallelr'   c          
     ó¬  ‡‡‡— t        | «      }|sd}t        |«      ‚t        |«      dk(  rAt        |d   t        j
                  t        j                  t        j                  f«      r|d   S |j                  d«      r‘t        |t        j
                  «      s8t        |t        j                  «      s|›dt        |d   «      ›}t        |«      ‚t        t        j                  d„ |D «       «      «      }t        t        |«      «      D 	ci c]  \  }}	|	|“Œ
 c}	}Št        ‰«      }
t!        t#        d„ t        d„ |D «       «      «      ˆfd	„¬
«      Š‰s|›d}t%        |«      ‚|dk(  rdn|j'                  d«      Š|D cg c]  }|j)                  «       ‘Œ }}d+ˆˆfd„}‰dv rt+        ||«      }nt#        ||«      } |j-                  ‰d¬«      j.                  |
Ž }t        |d   t        j
                  «      }|r|j1                  «       S |S ddlm} t        |t        j
                  «      r¦t7        d||¬«      }|dk(  r t9        t;        j<                  |«      «      }nD|dk(  r_t?        t;        j@                  |D cg c]  }|j)                  «       ‘Œ c}||dd¬«      «      j1                  |jC                  «       ¬«      }nà|dk(  r t9        t;        jD                  |«      «      }n»|dk(  r_t?        t;        jF                  |D cg c]  }|j)                  «       ‘Œ c}||dd¬«      «      j1                  |jC                  «       ¬«      }nW|dk(  r"t9        t;        jH                  |d¬«      «      }n0|dk(  r"t9        t;        jH                  |d¬«      «      }n	djK                  d„ tM        tN        «      D «       «      }d |› d!|›}t        |«      ‚t        |t        j                  «      rþt7        d||¬«      }|d"v r2t?        t;        j@                  ||||jQ                  d#«      d¬«      «      S |d$v r2t?        t;        jF                  ||||jQ                  d#«      d¬«      «      S |dk(  r!t?        t;        jR                  ||d¬%«      «      S |dk(  r!t?        t;        jR                  ||d¬%«      «      S djK                  d&„ tM        tN        «      D «       «      }d'|› d!|›}t        |«      ‚t        |t        j                  «      r1|dk(  rtU        t;        jV                  |«      «      }n{d(}t        |«      ‚t        |t        jX                  «      r7t[        t;        j\                  |D cg c]  }|j^                  ‘Œ c}|«      «      S d)t        |d   «      ›d*}t        |«      ‚|r|ja                  «       S |S c c}	}w c c}w c c}w c c}w c c}w ),u„  
    Combine multiple DataFrames, LazyFrames, or Series into a single object.

    Parameters
    ----------
    items
        DataFrames, LazyFrames, or Series to concatenate.
    how : {'vertical', 'vertical_relaxed', 'diagonal', 'diagonal_relaxed', 'horizontal', 'horizontal_extend', 'align', 'align_full', 'align_inner', 'align_left', 'align_right'}
        Note that `Series` only support the `vertical` strategy.

        * vertical: Applies multiple `vstack` operations.
        * vertical_relaxed: Same as `vertical`, but additionally coerces columns to
          their common supertype *if* they are mismatched (eg: Int32 â†’ Int64).
        * diagonal: Finds a union between the column schemas and fills missing column
          values with `null`.
        * diagonal_relaxed: Same as `diagonal`, but additionally coerces columns to
          their common supertype *if* they are mismatched (eg: Int32 â†’ Int64).
        * horizontal: Stacks Series from DataFrames horizontally. All input frames
          must have the same height; raises a `ShapeError` otherwise.
        * horizontal_extend: Same as `horizontal`, but pads shorter frames with `null`
          if the lengths don't match.
        * align, align_full, align_left, align_right: Combines frames horizontally,
          auto-determining the common key columns and aligning rows using the same
          logic as `align_frames` (note that "align" is an alias for "align_full").
          The "align" strategy determines the type of join used to align the frames,
          equivalent to the "how" parameter on `align_frames`. Note that the common
          join columns are automatically coalesced, but other column collisions
          will raise an error (if you need more control over this you should use
          a suitable `join` method directly).
    rechunk
        Make sure that the result data is in contiguous memory.
    parallel
        Only relevant for LazyFrames. This determines if the concatenated
        lazy computations may be executed in parallel.
    strict
        When how=`horizontal`, require all DataFrames to be the same height, raising an error if not.

        .. deprecated:: 1.42.1
            Use `how='horizontal'` (equal heights) or
            `how='horizontal_extend'` (pad with null) instead.

    Examples
    --------
    >>> df1 = pl.DataFrame({"a": [1], "b": [3]})
    >>> df2 = pl.DataFrame({"a": [2], "b": [4]})
    >>> pl.concat([df1, df2])  # default is 'vertical' strategy
    shape: (2, 2)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ a   â”† b   â”‚
    â”‚ --- â”† --- â”‚
    â”‚ i64 â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â”‚ 1   â”† 3   â”‚
    â”‚ 2   â”† 4   â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜

    >>> df1 = pl.DataFrame({"a": [1], "b": [3]})
    >>> df2 = pl.DataFrame({"a": [2.5], "b": [4]})
    >>> pl.concat([df1, df2], how="vertical_relaxed")  # 'a' coerced into f64
    shape: (2, 2)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ a   â”† b   â”‚
    â”‚ --- â”† --- â”‚
    â”‚ f64 â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â”‚ 1.0 â”† 3   â”‚
    â”‚ 2.5 â”† 4   â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜

    >>> df_h1 = pl.DataFrame({"l1": [1, 2], "l2": [3, 4]})
    >>> df_h2 = pl.DataFrame({"r1": [5, 6], "r2": [7, 8], "r3": [9, 10]})
    >>> pl.concat([df_h1, df_h2], how="horizontal_extend")
    shape: (2, 5)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ l1  â”† l2  â”† r1  â”† r2  â”† r3  â”‚
    â”‚ --- â”† --- â”† --- â”† --- â”† --- â”‚
    â”‚ i64 â”† i64 â”† i64 â”† i64 â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â”‚ 1   â”† 3   â”† 5   â”† 7   â”† 9   â”‚
    â”‚ 2   â”† 4   â”† 6   â”† 8   â”† 10  â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜

    The "diagonal" strategy allows for some frames to have missing columns,
    the values for which are filled with `null`:

    >>> df_d1 = pl.DataFrame({"a": [1], "b": [3]})
    >>> df_d2 = pl.DataFrame({"a": [2], "c": [4]})
    >>> pl.concat([df_d1, df_d2], how="diagonal")
    shape: (2, 3)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
    â”‚ a   â”† b    â”† c    â”‚
    â”‚ --- â”† ---  â”† ---  â”‚
    â”‚ i64 â”† i64  â”† i64  â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
    â”‚ 1   â”† 3    â”† null â”‚
    â”‚ 2   â”† null â”† 4    â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜

    The "align" strategies require at least one common column to align on:

    >>> df_a1 = pl.DataFrame({"id": [1, 2], "x": [3, 4]})
    >>> df_a2 = pl.DataFrame({"id": [2, 3], "y": [5, 6]})
    >>> df_a3 = pl.DataFrame({"id": [1, 3], "z": [7, 8]})
    >>> pl.concat([df_a1, df_a2, df_a3], how="align")  # equivalent to "align_full"
    shape: (3, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
    â”‚ id  â”† x    â”† y    â”† z    â”‚
    â”‚ --- â”† ---  â”† ---  â”† ---  â”‚
    â”‚ i64 â”† i64  â”† i64  â”† i64  â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
    â”‚ 1   â”† 3    â”† null â”† 7    â”‚
    â”‚ 2   â”† 4    â”† 5    â”† null â”‚
    â”‚ 3   â”† null â”† 6    â”† 8    â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
    >>> pl.concat([df_a1, df_a2, df_a3], how="align_left")
    shape: (2, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
    â”‚ id  â”† x   â”† y    â”† z    â”‚
    â”‚ --- â”† --- â”† ---  â”† ---  â”‚
    â”‚ i64 â”† i64 â”† i64  â”† i64  â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
    â”‚ 1   â”† 3   â”† null â”† 7    â”‚
    â”‚ 2   â”† 4   â”† 5    â”† null â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
    >>> pl.concat([df_a1, df_a2, df_a3], how="align_right")
    shape: (2, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ id  â”† x    â”† y    â”† z   â”‚
    â”‚ --- â”† ---  â”† ---  â”† --- â”‚
    â”‚ i64 â”† i64  â”† i64  â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â”‚ 1   â”† null â”† null â”† 7   â”‚
    â”‚ 3   â”† null â”† 6    â”† 8   â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
    >>> pl.concat([df_a1, df_a2, df_a3], how="align_inner")
    shape: (0, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ id  â”† x   â”† y   â”† z   â”‚
    â”‚ --- â”† --- â”† --- â”† --- â”‚
    â”‚ i64 â”† i64 â”† i64 â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
    úcannot concat empty listé   r   Úalignú strategy is not supported for c              3  ó<   K  — | ]  }|j                  «       –— Œ y ­w©N©Úcollect_schema©Ú.0Úes     r)   ú	<genexpr>zconcat.<locals>.<genexpr>í   ó   è ø€ Ò.QÀa¨q×/?Ñ/?×/AÑ.Qùó   ‚c                ó0   — t        | «      t        |«      z  S r5   ©Úset©ÚxÚys     r)   ú<lambda>zconcat.<locals>.<lambda>ò   ó   € œS ›V¤c¨!£f™_€ r+   c              3  ó<   K  — | ]  }|j                  «       –— Œ y ­wr5   r6   r8   s     r)   r;   zconcat.<locals>.<genexpr>ó   ó   è ø€ Ò8¨Qa×&Ñ&×(Ñ8ùr=   c                ó(   •— ‰j                  | d«      S ©Nr   ©Úget©ÚkÚkeys    €r)   rD   zconcat.<locals>.<lambda>õ   ó   ø€ ˜#Ÿ'™' ! Q›-€ r+   ©rN   ú- strategy requires at least one common columnÚfullÚalign_c                ó0   •— | j                  |‰‰dd¬«      S )NÚ
right_leftT©Úonr&   Úmaintain_orderÚcoalesce©Újoin©rB   rC   Úcommon_colsÚjoin_methods     €€r)   Újoin_fnzconcat.<locals>.join_fn  s(   ø€ Ø—6‘6ØØØØ+Øð ó ð r+   ©rR   ÚinnerT©ÚbyrX   ©ÚQueryOptFlagsÚconcat©r'   r,   Úvertical_relaxed©r-   r.   Úto_supertypesrX   ©ÚoptimizationsÚdiagonalÚdiagonal_relaxedr!   r#   Fú, c              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr5   ©Úrepr©r9   Úms     r)   r;   zconcat.<locals>.<genexpr><  ó   è ø€ ÒH¨A¤ Q§ÑHùó   ‚ú DataFrame `how` must be one of {ú}, got ©r,   rh   Úrelaxed©rm   rn   ©r.   r'   c              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr5   rq   rs   s     r)   r;   zconcat.<locals>.<genexpr>h  ru   rv   ú LazyFrame `how` must be one of {ú/Series only supports 'vertical' concat strategyúdid not expect type: ú in `concat`©rB   úpl.LazyFramerC   rƒ   Úreturnrƒ   )1Úlistr$   ÚlenÚ
isinstanceÚplr   r   r   Ú
startswithr   r   Ú	TypeErrorr   Úfrom_iterableÚ	enumerater   Úsortedr   r   ÚremoveprefixÚlazyr   ÚsortÚselectÚcollectÚpolars.lazyframe.opt_flagsre   r*   r   ÚplrÚ	concat_dfr   Ú	concat_lfÚ_eagerÚconcat_df_diagonalÚconcat_lf_diagonalÚconcat_df_horizontalr[   r
   r   ÚendswithÚconcat_lf_horizontalr   Úconcat_seriesr   r   Úconcat_exprÚ_pyexprr-   )Úitemsr&   r-   r.   r'   Úelemsr(   Úall_columnsrM   ÚvÚoutput_column_orderÚdfÚjoin_framesr_   ÚlfÚeagerre   ÚoutÚallowedr:   r]   r^   rN   s                       @@@r)   rf   rf   @   sW  ú€ ôp #' u£+€EáØ(ˆÜ˜‹oÐä
ˆ5ƒzQ‚œ:Øˆa‰”2—<‘<¤§¡¬B¯L©LÐ9ôð Q‰xˆà
‡~~gÕÜ'Ø”2—<‘<ô
ä*Ø”2—<‘<ô
ð GÐ:Ô;NÈuÐUVÉxÓ;XÐ:[Ð\ˆCÜ˜C“.Ð ô œ5×.Ñ.Ñ.QÈ5Ô.QÓQÓRˆÜ )¬.¸Ó*EÓ F×G™˜˜1ˆq!‰tÓGˆÜ" 3›iÐÜÜÙ,ÜÑ8°%Ô8Ó8óó (ô
ˆñ ØGÐHÐIˆCÜ'¨Ó,Ð,ð
 ˜W’n‰F¨#×*:Ñ*:¸8Ó*Dð 	ð ,1Ö1 Rr—w‘w•yÐ1ˆÐ1ö	ð Ð+Ñ+ä  ¨+Ó6‰Bô ˜ Ó-ˆBØ@ˆRW‰W˜°DˆWÓ9×@Ñ@ÐBUÐVˆä˜5 ™8¤R§\¡\Ó2ˆÙ$ˆrz‰z‹|Ð,¨"Ð,õ 9ä ¤r§|¡|Õ4Ü*¨8°SÀÔHˆà*ÒÜœ#Ÿ-™-¨Ó.Ó/ŠCØÐ&Ò&ÜÜ—‘Ø).Ö/ 2R—W‘W•YÒ/Ø#Ø%Ø"&Ø#'ôó÷ ‰g M×$8Ñ$8Ó$:ˆgÓ;ò ð JÒÜœ#×0Ñ0°Ó7Ó8ŠCØÐ&Ò&ÜÜ×&Ñ&Ø).Ö/ 2R—W‘W•YÒ/Ø#Ø%Ø"&Ø#'ôó÷ ‰g M×$8Ñ$8Ó$:ˆgÓ;ò ð LÒ Üœ#×2Ñ2°5ÀÔFÓGŠCØÐ'Ò'Üœ#×2Ñ2°5ÀÔGÓHŠCà—i‘iÑH´¼,Ó1GÔHÓHˆGØ5°g°Y¸hÀsÀgÐNˆCÜ˜S“/Ð!ä	! %¬¯©Ô	6Ü*¨8°SÀÔHˆàÐ2Ñ2ÜÜ—‘ØØ#Ø%Ø"%§,¡,¨yÓ"9Ø#'ôóð ð Ð4Ñ4ÜÜ×&Ñ&ØØ#Ø%Ø"%§,¡,¨yÓ"9Ø#'ôóð ð LÒ ÜÜ×(Ñ(ØØ%Øôóð ð Ð'Ò'ÜÜ×(Ñ(ØØ%Ø ôóð ð —i‘iÑH´¼,Ó1GÔHÓHˆGØ5°g°Y¸hÀsÀgÐNˆCÜ˜S“/Ð!ä	! %¬¯©Ô	3Ø*ÒÜœ×*Ñ*¨5Ó1Ó2‰CàCˆCÜ˜S“/Ð!ä	! %¬¯©Ô	1ÜœŸ™¸UÖ)C¸¨!¯)«)Ò)CÀWÓMÓNÐNà%Ô&9¸%À¹(Ó&CÐ%FÀlÐSˆÜ˜‹nÐáØ{‰{‹}ÐØ€Jùó[ Hùò& 2ùòD 0ùò 0ùòH *Ds   ÄV<ÆWÊWÌ
WÕ,W)r&   r'   c          
     ó*  ‡‡‡— t        | «      }|sd}t        |«      ‚t        |«      dk(  rAt        |d   t        j
                  t        j                  t        j                  f«      r|d   S |j                  d«      r‘t        |t        j
                  «      s8t        |t        j                  «      s|›dt        |d   «      ›}t        |«      ‚t        t        j                  d„ |D «       «      «      }t        t        |«      «      D ci c]  \  }}||“Œ
 c}}Št        ‰«      }t!        t#        d„ t        d„ |D «       «      «      ˆfd	„¬
«      Š‰s|›d}t%        |«      ‚|dk(  rdn|j'                  d«      Š|D 	cg c]  }	|	j)                  «       ‘Œ }
}	d(ˆˆfd„}‰dv rt+        ||
«      }nt#        ||
«      } |j-                  ‰d¬«      j.                  |Ž }t        |d   t        j
                  «      }|r|j1                  «       S |S ddlm} t        |t        j
                  «      rxt7        d||¬«      }|dv rnt9        t;        j<                  |D 	cg c]  }	|	j)                  «       ‘Œ c}	dd|j?                  d«      d¬«      «      j1                  |jA                  «       ¬«      }|S |dv rnt9        t;        jB                  |D 	cg c]  }	|	j)                  «       ‘Œ c}	dd|j?                  d«      d¬«      «      j1                  |jA                  «       ¬«      }|S |dk(  r"tE        t;        jF                  |d¬«      «      }|S |dk(  r"tE        t;        jF                  |d¬«      «      }|S djI                  d„ tK        tL        «      D «       «      }d|› d |›}t        |«      ‚t        |t        j                  «      rþt7        d||¬«      }|dv r2t9        t;        j<                  |dd|j?                  d«      d¬«      «      S |dv r2t9        t;        jB                  |dd|j?                  d«      d¬«      «      S |dk(  r!t9        t;        jN                  |dd¬!«      «      S |dk(  r!t9        t;        jN                  |dd¬!«      «      S djI                  d"„ tK        tL        «      D «       «      }d#|› d |›}t        |«      ‚t        |t        j                  «      r2|d$k(  r tQ        t;        jR                  |«      «      }|S d%}t        |«      ‚t        |t        jT                  «      r7tW        t;        jX                  |D cg c]  }|jZ                  ‘Œ c}d«      «      S d&t        |d   «      ›d'}t        |«      ‚c c}}w c c}	w c c}	w c c}	w c c}w ))uS  
    Combine multiple DataFrames, LazyFrames, or Series into a single object.

    .. warning::
        This function does not guarantee any specific ordering of rows in the result.
        If you need predictable row ordering, use `pl.concat()` instead.

    Parameters
    ----------
    items
        DataFrames, LazyFrames, or Series to concatenate.
    how : {'vertical', 'vertical_relaxed', 'diagonal', 'diagonal_relaxed', 'horizontal', 'horizontal_extend', 'align', 'align_full', 'align_inner', 'align_left', 'align_right'}
        Note that `Series` only support the `vertical` strategy.

        * vertical: Applies multiple `vstack` operations.
        * vertical_relaxed: Same as `vertical`, but additionally coerces columns to
          their common supertype *if* they are mismatched (eg: Int32 â†’ Int64).
        * diagonal: Finds a union between the column schemas and fills missing column
          values with `null`.
        * diagonal_relaxed: Same as `diagonal`, but additionally coerces columns to
          their common supertype *if* they are mismatched (eg: Int32 â†’ Int64).
        * horizontal: Stacks Series from DataFrames horizontally. All input frames
          must have the same height; raises a `ShapeError` otherwise.
        * horizontal_extend: Same as `horizontal`, but pads shorter frames with `null`
          if the lengths don't match.
        * align, align_full, align_left, align_right: Combines frames horizontally,
          auto-determining the common key columns and aligning rows using the same
          logic as `align_frames` (note that "align" is an alias for "align_full").
          The "align" strategy determines the type of join used to align the frames,
          equivalent to the "how" parameter on `align_frames`. Note that the common
          join columns are automatically coalesced, but other column collisions
          will raise an error (if you need more control over this you should use
          a suitable `join` method directly).
    strict
        When how=`horizontal`, require all DataFrames to be the same height, raising an error if not.

        .. deprecated:: 1.42.1
            Use `how='horizontal'` (equal heights) or
            `how='horizontal_extend'` (pad with null) instead.

    Examples
    --------
    >>> df1 = pl.DataFrame({"a": [1], "b": [3]})
    >>> df2 = pl.DataFrame({"a": [2], "b": [4]})
    >>> pl.union([df1, df2])  # default is 'vertical' strategy
    shape: (2, 2)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ a   â”† b   â”‚
    â”‚ --- â”† --- â”‚
    â”‚ i64 â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â”‚ 1   â”† 3   â”‚
    â”‚ 2   â”† 4   â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜

    >>> df1 = pl.DataFrame({"a": [1], "b": [3]})
    >>> df2 = pl.DataFrame({"a": [2.5], "b": [4]})
    >>> pl.union([df1, df2], how="vertical_relaxed")  # 'a' coerced into f64
    shape: (2, 2)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ a   â”† b   â”‚
    â”‚ --- â”† --- â”‚
    â”‚ f64 â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â”‚ 1.0 â”† 3   â”‚
    â”‚ 2.5 â”† 4   â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜

    >>> df_h1 = pl.DataFrame({"l1": [1, 2], "l2": [3, 4]})
    >>> df_h2 = pl.DataFrame({"r1": [5, 6], "r2": [7, 8], "r3": [9, 10]})
    >>> pl.union([df_h1, df_h2], how="horizontal_extend")
    shape: (2, 5)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ l1  â”† l2  â”† r1  â”† r2  â”† r3  â”‚
    â”‚ --- â”† --- â”† --- â”† --- â”† --- â”‚
    â”‚ i64 â”† i64 â”† i64 â”† i64 â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â”‚ 1   â”† 3   â”† 5   â”† 7   â”† 9   â”‚
    â”‚ 2   â”† 4   â”† 6   â”† 8   â”† 10  â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜

    The "diagonal" strategy allows for some frames to have missing columns,
    the values for which are filled with `null`:

    >>> df_d1 = pl.DataFrame({"a": [1], "b": [3]})
    >>> df_d2 = pl.DataFrame({"a": [2], "c": [4]})
    >>> pl.union([df_d1, df_d2], how="diagonal")
    shape: (2, 3)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
    â”‚ a   â”† b    â”† c    â”‚
    â”‚ --- â”† ---  â”† ---  â”‚
    â”‚ i64 â”† i64  â”† i64  â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
    â”‚ 1   â”† 3    â”† null â”‚
    â”‚ 2   â”† null â”† 4    â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜

    The "align" strategies require at least one common column to align on:

    >>> df_a1 = pl.DataFrame({"id": [1, 2], "x": [3, 4]})
    >>> df_a2 = pl.DataFrame({"id": [2, 3], "y": [5, 6]})
    >>> df_a3 = pl.DataFrame({"id": [1, 3], "z": [7, 8]})
    >>> pl.union([df_a1, df_a2, df_a3], how="align")  # equivalent to "align_full"
    shape: (3, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
    â”‚ id  â”† x    â”† y    â”† z    â”‚
    â”‚ --- â”† ---  â”† ---  â”† ---  â”‚
    â”‚ i64 â”† i64  â”† i64  â”† i64  â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
    â”‚ 1   â”† 3    â”† null â”† 7    â”‚
    â”‚ 2   â”† 4    â”† 5    â”† null â”‚
    â”‚ 3   â”† null â”† 6    â”† 8    â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
    >>> pl.union([df_a1, df_a2, df_a3], how="align_left")
    shape: (2, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
    â”‚ id  â”† x   â”† y    â”† z    â”‚
    â”‚ --- â”† --- â”† ---  â”† ---  â”‚
    â”‚ i64 â”† i64 â”† i64  â”† i64  â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
    â”‚ 1   â”† 3   â”† null â”† 7    â”‚
    â”‚ 2   â”† 4   â”† 5    â”† null â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
    >>> pl.union([df_a1, df_a2, df_a3], how="align_right")
    shape: (2, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ id  â”† x    â”† y    â”† z   â”‚
    â”‚ --- â”† ---  â”† ---  â”† --- â”‚
    â”‚ i64 â”† i64  â”† i64  â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â”‚ 1   â”† null â”† null â”† 7   â”‚
    â”‚ 3   â”† null â”† 6    â”† 8   â”‚
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
    >>> pl.union([df_a1, df_a2, df_a3], how="align_inner")
    shape: (0, 4)
    â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ id  â”† x   â”† y   â”† z   â”‚
    â”‚ --- â”† --- â”† --- â”† --- â”‚
    â”‚ i64 â”† i64 â”† i64 â”† i64 â”‚
    â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
    r0   r1   r   r2   r3   c              3  ó<   K  — | ]  }|j                  «       –— Œ y ­wr5   r6   r8   s     r)   r;   zunion.<locals>.<genexpr>(  r<   r=   c                ó0   — t        | «      t        |«      z  S r5   r?   rA   s     r)   rD   zunion.<locals>.<lambda>-  rE   r+   c              3  ó<   K  — | ]  }|j                  «       –— Œ y ­wr5   r6   r8   s     r)   r;   zunion.<locals>.<genexpr>.  rG   r=   c                ó(   •— ‰j                  | d«      S rI   rJ   rL   s    €r)   rD   zunion.<locals>.<lambda>0  rO   r+   rP   rQ   rR   rS   c                ó0   •— | j                  |‰‰dd¬«      S )NÚnoneTrV   rZ   r\   s     €€r)   r_   zunion.<locals>.join_fn>  s(   ø€ Ø—6‘6ØØØØ%Øð ó ð r+   r`   Frb   rd   Úunionrg   ry   Trz   ri   rk   r{   r!   r#   ro   c              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr5   rq   rs   s     r)   r;   zunion.<locals>.<genexpr>r  ru   rv   rw   rx   r|   c              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr5   rq   rs   s     r)   r;   zunion.<locals>.<genexpr>ž  ru   rv   r~   r,   r   r€   r   r‚   ).r…   r$   r†   r‡   rˆ   r   r   r   r‰   r   r   rŠ   r   r‹   rŒ   r   r   r   r   rŽ   r   r   r   r‘   r’   r“   re   r*   r   r”   r–   r›   r—   r™   r   rš   r[   r
   r   rœ   r   r   r   r   rž   rŸ   )r    r&   r'   r¡   r(   r¢   rM   r£   r¤   r¥   r¦   r_   r§   r¨   re   r©   rª   r:   r]   r^   rN   s                     @@@r)   r²   r²   ~  sO  ú€ ôj #' u£+€EáØ(ˆÜ˜‹oÐä
ˆ5ƒzQ‚œ:Øˆa‰”2—<‘<¤§¡¬B¯L©LÐ9ôð Q‰xˆà
‡~~gÕÜ'Ø”2—<‘<ô
ä*Ø”2—<‘<ô
ð GÐ:Ô;NÈuÐUVÉxÓ;XÐ:[Ð\ˆCÜ˜C“.Ð ô œ5×.Ñ.Ñ.QÈ5Ô.QÓQÓRˆÜ )¬.¸Ó*EÓ F×G™˜˜1ˆq!‰tÓGˆÜ" 3›iÐÜÜÙ,ÜÑ8°%Ô8Ó8óó (ô
ˆñ ØGÐHÐIˆCÜ'¨Ó,Ð,ð
 ˜W’n‰F¨#×*:Ñ*:¸8Ó*Dð 	ð ,1Ö1 Rr—w‘w•yÐ1ˆÐ1ö	ð Ð+Ñ+ä  ¨+Ó6‰Bô ˜ Ó-ˆBØAˆRW‰W˜°EˆWÓ:×AÑAÐCVÐWˆä˜5 ™8¤R§\¡\Ó2ˆÙ$ˆrz‰z‹|Ð,¨"Ð,õ 9ä ¤r§|¡|Õ4Ü*¨7°CÀÔGˆàÐ2Ñ2ÜÜ—‘Ø).Ö/ 2R—W‘W•YÒ/Ø!Ø!Ø"%§,¡,¨yÓ"9Ø#(ôó÷ ‰g M×$8Ñ$8Ó$:ˆgÓ;ð ðj €JðY Ð4Ñ4ÜÜ×&Ñ&Ø).Ö/ 2R—W‘W•YÒ/Ø!Ø!Ø"%§,¡,¨yÓ"9Ø#(ôó÷ ‰g M×$8Ñ$8Ó$:ˆgÓ;ð ðV €JðE LÒ Üœ#×2Ñ2°5ÀÔFÓGˆCðB €JðA Ð'Ò'Üœ#×2Ñ2°5ÀÔGÓHˆCð~ €Jð{ —i‘iÑH´¼,Ó1GÔHÓHˆGØ5°g°Y¸hÀsÀgÐNˆCÜ˜S“/Ð!ä	! %¬¯©Ô	6Ü*¨7°CÀÔGˆàÐ2Ñ2ÜÜ—‘ØØ!Ø!Ø"%§,¡,¨yÓ"9Ø#(ôóð ð Ð4Ñ4ÜÜ×&Ñ&ØØ!Ø!Ø"%§,¡,¨yÓ"9Ø#(ôóð ð LÒ ÜÜ×(Ñ(ØØ!Øôóð ð Ð'Ò'ÜÜ×(Ñ(ØØ!Ø ôóð ð —i‘iÑH´¼,Ó1GÔHÓHˆGØ5°g°Y¸hÀsÀgÐNˆCÜ˜S“/Ð!ä	! %¬¯©Ô	3Ø*ÒÜœ×*Ñ*¨5Ó1Ó2ˆCð €Jð DˆCÜ˜S“/Ð!ä	! %¬¯©Ô	1ÜœŸ™¸UÖ)C¸¨!¯)«)Ò)CÀUÓKÓLÐLà%Ô&9¸%À¹(Ó&CÐ%FÀlÐSˆÜ˜‹nÐùóI Hùò& 2ùò@ 0ùò 0ùòH *Ds   ÄU;ÆVÉVËVÔ?V)rX   c               ó&  ‡‡— t        | «      }|sd}t        |«      ‚t        |«      dk(  r2t        |d   t        j
                  t        j                  f«      r|d   S t        |t        j
                  «      s6t        |t        j                  «      sdt        |d   «      ›}t        |«      ‚|D cg c]  }|j                  «       ‘Œ }}dˆˆfd„}t        ||«      }t        |d   t        j
                  «      }	|	r|j                  «       S |S c c}w )u`  
    Merge multiple sorted DataFrames or LazyFrames by the sorted key.

    The output of this operation will also be sorted.
    It is the callers responsibility that the frames
    are sorted in ascending order by that key otherwise
    the output will not make sense.

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

    Parameters
    ----------
    items
        DataFrames or LazyFrames to merge.
    key
        Key that is sorted.
    maintain_order
        If ``True``, the output is guaranteed to have left-biased ordering
        for equal keys: rows from the left frame appear before rows from
        the right frame when their keys are equal.

    Examples
    --------
    >>> df0 = pl.DataFrame(
    ...     {"name": ["steve", "elise", "bob"], "age": [42, 44, 18]}
    ... ).sort("age")
    >>> df1 = pl.DataFrame(
    ...     {"name": ["anna", "megan", "steve", "thomas"], "age": [21, 33, 17, 20]}
    ... ).sort("age")
    >>> df2 = pl.DataFrame({"name": ["ida", "maya"], "age": [37, 27]}).sort("age")
    >>> pl.merge_sorted([df0, df1, df2], key="age")
    shape: (9, 2)
    â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    â”‚ name   â”† age â”‚
    â”‚ ---    â”† --- â”‚
    â”‚ str    â”† i64 â”‚
    â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    â”‚ steve  â”† 17  â”‚
    â”‚ bob    â”† 18  â”‚
    â”‚ thomas â”† 20  â”‚
    â”‚ anna   â”† 21  â”‚
    â”‚ maya   â”† 27  â”‚
    â”‚ megan  â”† 33  â”‚
    â”‚ ida    â”† 37  â”‚
    â”‚ steve  â”† 42  â”‚
    â”‚ elise  â”† 44  â”‚
    â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜


    Notes
    -----
    Unless ``maintain_order=True``, no guarantee is given over the output
    row order when the key is equal between dataframes.

    The key must be sorted in ascending order.
    zcannot merge_sort empty listr1   r   z"merge_sorted is not supported for c                ó,   •— | j                  |‰‰¬«      S )N)rN   rX   )Úmerge_sorted)rB   rC   rN   rX   s     €€r)   Ú	reduce_fnzmerge_sorted.<locals>.reduce_fn  s   ø€ Ø~‰~˜a S¸ˆ~ÓHÐHr+   r‚   )r…   r$   r†   r‡   rˆ   r   r   r   r   rŠ   r   r   r’   )
r    rN   rX   r¡   r(   r¥   Úframesr¸   r§   r¨   s
    ``       r)   r·   r·   ²  sí   ù€ ôB #' u£+€EáØ,ˆÜ˜‹oÐÜ
ˆ5ƒzQ‚œ: e¨A¡h´·±¼r¿|¹|Ð0LÔMØQ‰xˆä#ØŒr|‰|ôä&ØŒr|‰|ôð 3Ô3FÀuÈQÁxÓ3PÐ2SÐTˆÜ˜‹nÐà"'Ö(˜Bˆbg‰giÐ(€FÐ(öIô 
˜ FÓ	+€BÜu˜Q‘x¤§¡Ó.€EÙ ˆ2:‰:‹<Ð( bÐ(ùò )s   Â1DrR   )r&   Ú
descendingc                óî   ‡ ‡— t        |«      dk\  }	 	 	 	 	 	 d	ˆ ˆfd„}ddlm} t        ||«      d   j	                  ‰ |d¬«      }|r.|j                  |j                  «       ¬«      j                  «       }|S )
zLCreate a single master frame with all rows aligned on the common key values.éú   c           
     óT   •— | |c\  }}\  }}||j                  |‰‰d|› ddd¬«      fS )Nú:TrU   )r&   rW   ÚsuffixÚnulls_equalrY   rX   rZ   )Úidx_xÚidx_yÚ_rB   Úy_idxrC   Úalign_onr&   s         €€r)   Ú	join_funcz"_alignment_join.<locals>.join_func  sQ   ø€ ð # EÐ‰ˆˆA‘
˜Øa—f‘fØØØØug;ØØØ'ð ó 
ð 
ð 	
r+   r   rd   r1   T)rc   rº   rX   rk   )rÁ   útuple[int, LazyFrame]rÂ   rÇ   r„   rÇ   )r†   Úpolars.lazyframere   r   r   r’   r±   r   )rÅ   r&   rº   Ú
idx_framesÚpost_align_collectrÆ   re   Újoineds   ``      r)   Ú_alignment_joinrÌ     sŒ   ù€ ô ˜Z›¨CÑ/Ðð
Ø$ð
à$ð
ð 
ö
õ /äI˜zÓ*¨1Ñ-×2Ñ2Ø 
¸4ð 3ó €Fñ Ø—‘¨m×.@Ñ.@Ó.BÓC×HÑHÓJˆØ€Mr+   )r&   r‘   rº   c                ó„  — |sg S t        |«      dk(  r2t        |d   t        j                  t        j                  f«      s|d   }t        |t
        t        f«      rt        |«      }t        |D ch c]  }t        |«      ’Œ c}«      dk7  rd}t        |«      ‚t        |d   t        j                  «      }t        | t        «      st        | t        «      s| gn| } | D cg c]8  }t        |t        j                  «      r|j                  j                  «       n|‘Œ: }	}t        |«      D 
cg c]  \  }
}|
|j!                  «       f‘Œ }}
}t#        ||	||dœŽ}t%        |j'                  «       «      }g }|D ]  \  }
}d|
› }|j'                  «       D cg c]G  }|› |› |v r(t)        j*                  |› |› «      j-                  |«      nt)        j*                  |«      ‘ŒI }} |j.                  |Ž }||j/                  |«      }|j1                  |«       ŒŸ |rt)        j2                  |«      S |S c c}w c c}w c c}}
w c c}w )u#  
    Align a sequence of frames using common values from one or more columns as a key.

    Frames that do not contain the given key values have rows injected (with nulls
    filling the non-key columns), and each resulting frame is sorted by the key.

    The original column order of input frames is not changed unless `select` is
    specified (in which case the final column order is determined from that). In the
    case where duplicate key values exist, the alignment behaviour is determined by
    the given alignment strategy specified in the `how` parameter (by default this
    is a full outer join, but if your data is suitable you can get a large speedup
    by setting `how="left"` instead).

    Note that this function does not result in a joined frame - you receive the same
    number of frames back that you passed in, but each is now aligned by key and has
    the same number of rows.

    Parameters
    ----------
    frames
        Sequence of DataFrames or LazyFrames.
    on
        One or more columns whose unique values will be used to align the frames.
    select
        Optional post-alignment column select to constrain and/or order
        the columns returned from the newly aligned frames.
    descending
        Sort the alignment column values in descending order; can be a single
        boolean or a list of booleans associated with each column in `on`.
    how
        By default the row alignment values are determined using a full outer join
        strategy across all frames; if you know that the first frame contains all
        required keys, you can set `how="left"` for a large performance increase.

    Examples
    --------
    >>> from datetime import date
    >>> df1 = pl.DataFrame(
    ...     {
    ...         "dt": [date(2022, 9, 1), date(2022, 9, 2), date(2022, 9, 3)],
    ...         "x": [3.5, 4.0, 1.0],
    ...         "y": [10.0, 2.5, 1.5],
    ...     }
    ... )
    >>> df2 = pl.DataFrame(
    ...     {
    ...         "dt": [date(2022, 9, 2), date(2022, 9, 3), date(2022, 9, 1)],
    ...         "x": [8.0, 1.0, 3.5],
    ...         "y": [1.5, 12.0, 5.0],
    ...     }
    ... )
    >>> df3 = pl.DataFrame(
    ...     {
    ...         "dt": [date(2022, 9, 3), date(2022, 9, 2)],
    ...         "x": [2.0, 5.0],
    ...         "y": [2.5, 2.0],
    ...     }
    ... )  # doctest: +IGNORE_RESULT
    >>> pl.Config.set_tbl_formatting("UTF8_FULL")  # doctest: +IGNORE_RESULT
    #
    # df1                              df2                              df3
    # shape: (3, 3)                    shape: (3, 3)                    shape: (2, 3)
    # â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”      â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”      â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
    # â”‚ dt         â”† x   â”† y    â”‚      â”‚ dt         â”† x   â”† y    â”‚      â”‚ dt         â”† x   â”† y   â”‚
    # â”‚ ---        â”† --- â”† ---  â”‚      â”‚ ---        â”† --- â”† ---  â”‚      â”‚ ---        â”† --- â”† --- â”‚
    # â”‚ date       â”† f64 â”† f64  â”‚      â”‚ date       â”† f64 â”† f64  â”‚      â”‚ date       â”† f64 â”† f64 â”‚
    # â•žâ•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡      â•žâ•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡      â•žâ•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
    # â”‚ 2022-09-01 â”† 3.5 â”† 10.0 â”‚\  ,->â”‚ 2022-09-02 â”† 8.0 â”† 1.5  â”‚\  ,->â”‚ 2022-09-03 â”† 2.0 â”† 2.5 â”‚
    # â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤ \/   â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤ \/   â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ”¤
    # â”‚ 2022-09-02 â”† 4.0 â”† 2.5  â”‚_/\,->â”‚ 2022-09-03 â”† 1.0 â”† 12.0 â”‚_/`-->â”‚ 2022-09-02 â”† 5.0 â”† 2.0 â”‚
    # â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤  /\  â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤      â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
    # â”‚ 2022-09-03 â”† 1.0 â”† 1.5  â”‚_/  `>â”‚ 2022-09-01 â”† 3.5 â”† 5.0  â”‚-//-
    # â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜      â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
    ...

    Align frames by the "dt" column:

    >>> af1, af2, af3 = pl.align_frames(
    ...     df1, df2, df3, on="dt"
    ... )  # doctest: +IGNORE_RESULT
    #
    # df1                              df2                              df3
    # shape: (3, 3)                    shape: (3, 3)                    shape: (3, 3)
    # â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”      â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”      â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
    # â”‚ dt         â”† x   â”† y    â”‚      â”‚ dt         â”† x   â”† y    â”‚      â”‚ dt         â”† x    â”† y    â”‚
    # â”‚ ---        â”† --- â”† ---  â”‚      â”‚ ---        â”† --- â”† ---  â”‚      â”‚ ---        â”† ---  â”† ---  â”‚
    # â”‚ date       â”† f64 â”† f64  â”‚      â”‚ date       â”† f64 â”† f64  â”‚      â”‚ date       â”† f64  â”† f64  â”‚
    # â•žâ•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡      â•žâ•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡      â•žâ•â•â•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
    # â”‚ 2022-09-01 â”† 3.5 â”† 10.0 â”‚----->â”‚ 2022-09-01 â”† 3.5 â”† 5.0  â”‚----->â”‚ 2022-09-01 â”† null â”† null â”‚
    # â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤      â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤      â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤
    # â”‚ 2022-09-02 â”† 4.0 â”† 2.5  â”‚----->â”‚ 2022-09-02 â”† 8.0 â”† 1.5  â”‚----->â”‚ 2022-09-02 â”† 5.0  â”† 2.0  â”‚
    # â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤      â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤      â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤
    # â”‚ 2022-09-03 â”† 1.0 â”† 1.5  â”‚----->â”‚ 2022-09-03 â”† 1.0 â”† 12.0 â”‚----->â”‚ 2022-09-03 â”† 2.0  â”† 2.5  â”‚
    # â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜      â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜      â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
    ...

    Align frames by "dt" using "left" alignment, but keep only cols "x" and "y":

    >>> af1, af2, af3 = pl.align_frames(
    ...     df1, df2, df3, on="dt", select=["x", "y"], how="left"
    ... )  # doctest: +IGNORE_RESULT
    #
    # af1                 af2                 af3
    # shape: (3, 3)       shape: (3, 3)       shape: (3, 3)
    # â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”      â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”      â”Œâ”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
    # â”‚ x   â”† y    â”‚      â”‚ x   â”† y    â”‚      â”‚ x    â”† y    â”‚
    # â”‚ --- â”† ---  â”‚      â”‚ --- â”† ---  â”‚      â”‚ ---  â”† ---  â”‚
    # â”‚ f64 â”† f64  â”‚      â”‚ f64 â”† f64  â”‚      â”‚ f64  â”† f64  â”‚
    # â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡      â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡      â•žâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
    # â”‚ 3.5 â”† 10.0 â”‚      â”‚ 3.5 â”† 5.0  â”‚      â”‚ null â”† null â”‚
    # â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤      â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤      â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤
    # â”‚ 4.0 â”† 2.5  â”‚      â”‚ 8.0 â”† 1.5  â”‚      â”‚ 5.0  â”† 2.0  â”‚
    # â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤      â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤      â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¼â•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤
    # â”‚ 1.0 â”† 1.5  â”‚      â”‚ 1.0 â”† 12.0 â”‚      â”‚ 2.0  â”† 2.5  â”‚
    # â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜      â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜      â””â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
    ...

    Now data is aligned, and you can easily calculate the row-wise dot product:

    >>> (af1 * af2 * af3).fill_null(0).select(pl.sum_horizontal("*").alias("dot"))
    shape: (3, 1)
    â”Œâ”€â”€â”€â”€â”€â”€â”€â”
    â”‚ dot   â”‚
    â”‚ ---   â”‚
    â”‚ f64   â”‚
    â•žâ•â•â•â•â•â•â•â•¡
    â”‚ 0.0   â”‚
    â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤
    â”‚ 167.5 â”‚
    â”œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ•Œâ”¤
    â”‚ 47.0  â”‚
    â””â”€â”€â”€â”€â”€â”€â”€â”˜
    r1   r   zJinput frames must be of a consistent type (all LazyFrame or all DataFrame))rÅ   r&   rº   r¾   )r†   r‡   rˆ   r   r   r   r   ÚtupleÚtyperŠ   Ústrr   r   ÚmetaÚoutput_namerŒ   r   rÌ   r@   r7   ÚFÚcolÚaliasr‘   ÚappendÚcollect_all)rW   r&   r‘   rº   r¹   Úfr(   r¨   ÚcrÅ   ÚidxÚframerÉ   Úalignment_frameÚaligned_colsÚaligned_framesr§   ÚsfxÚdf_colss                      r)   Úalign_framesrá   1  s  € ñX Øˆ	ä
ˆ6ƒ{aÒ¤
¨6°!©9´r·|±|ÄRÇ\Á\Ð6RÔ SØ˜‘ˆÜ&œ9¤hÐ/Ô0Üv“ˆä
˜VÖ$˜ŒDGÒ$Ó%¨Ò*àXð 	ô ˜‹nÐäv˜a‘y¤"§,¡,Ó/€EÜ˜R¤Ô%¬Z¸¼HÔ-Eˆ"‰ÈB€BØQSÖTÈA¬°A´r·w±wÔ)?—‘×#Ñ#Ô%ÀQÑFÐT€HÐTô 9BÀ&Ó8I×J©*¨#¨u3˜Ÿ
™
›Ò%ÐJ€JÑJÜ%Ø	˜h¨C¸Jò€Oô
 ×5Ñ5Ó7Ó8€LØ€NØò 	!‰ˆˆRØ#ˆiˆð ×&Ñ&Ó(ö
àð /0¨S°°¨;¸,Ñ+FŒAE‰EQC˜u+Ó×$Ñ$ QÔ'ÌAÏEÉEÐRSËHÑTð
ˆð 
ð #ˆO×"Ñ" GÐ,ˆØÐØ—‘˜Ó ˆAØ×Ñ˜aÕ ð	!ñ -2Œ1=‰=˜Ó(ÐE°~ÐEùò? %ùò Uùó Kùò
s   Á/H-Ã=H2Ä+H7ÆAH=)r%   rÐ   r&   r   r'   úbool | Noner„   r   )r    úIterable[PolarsType]r&   r   r-   Úboolr.   rä   r'   râ   r„   r   )r    rã   r&   r   r'   râ   r„   r   )r    rã   rN   rÐ   rX   rä   r„   r   )
rÉ   rÇ   rÅ   z	list[str]r&   r   rº   úbool | Sequence[bool]r„   r   )r¹   zFrameType | Iterable[FrameType]rW   zBstr | Expr | Sequence[str] | Sequence[Expr] | Sequence[str | Expr]r&   r   r‘   z(str | Expr | Sequence[str | Expr] | Nonerº   rå   r„   zlist[FrameType]):Ú
__future__r   Ú
contextlibÚcollections.abcr   r   r   Ú	functoolsr   Ú	itertoolsr   Útypingr	   r
   Úpolars._reexportÚ	_reexportrˆ   Úpolarsr   rÓ   Úpolars._typingr   Úpolars._utils.deprecationr   Úpolars._utils.reduce_balancedr   Úpolars._utils.unstabler   Úpolars._utils.variousr   r   r   Úpolars._utils.wrapr   r   r   r   Úpolars.exceptionsr   ÚsuppressÚImportErrorÚpolars._plrÚ_plrr”   r   r   r   r   r   r   r   r   r*   rf   r²   r·   rÌ   rá   © r+   r)   ú<module>rû      s  ðÝ "ã ß 9Ñ 9Ý Ý ß *å Ý !Ý 'Ý ?Ý 9Ý +÷ñ ÷
 DÓ CÝ 3à€Z×Ñ˜Ó%ñ Ý÷ñ Ý(ç9Ó9ßBÑBðØðØ)ðØ6AðàóðD #ØØØñ{Øð{ð 
ð{ð ð	{ð
 ð{ð ð{ð ó{ðB
 #Øñ	qØðqð 
ðqð ð	qð
 óqñh	 
ƒð
 !ñ	W)ØðW)à	ðW)ð ð	W)ð
 òW)ó ðW)ðz Ø(-ñ	!Ø&ð!àð!ð 
ð!ð &ð	!ð
 ó!ðN Ø7;Ø(-ñsFØ,ðsFàJðsFð 
ðsFð 5ð	sFð
 &ðsFð ôsF÷uð ús   Á;DÄD