ó
    à'·håb  ã                  óÐ  • S SK Jr  S SK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Jr  S SKJr  S SKJr  S SKJr  S S	KJrJr  S S
KJrJrJrJr  S SKJr  \R@                  " \!5         S SK"J#r$  SSS5        \(       a  S SKJ%r%  S SKJ&r&J'r'J(r(J)r)  S SKJ*r*J+r+J,r,  SSSS.         SS jjr-SSS.         SS jjr.SSSS.           SS jjr/g! , (       d  f       No= f)é    )ÚannotationsN)Ú	GeneratorÚIteratorÚSequence)Úreduce)Úchain)ÚTYPE_CHECKINGÚget_args)Ú	functions)ÚConcatMethod)Úordered_uniqueÚqualified_type_name)Úwrap_dfÚ	wrap_exprÚwrap_ldfÚwrap_s)ÚInvalidOperationError)ÚIterable)Ú	DataFrameÚExprÚ	LazyFrameÚSeries)Ú	FrameTypeÚJoinStrategyÚ
PolarsTypeÚverticalFT)ÚhowÚrechunkÚparallelc          
     ó   ^^^• [        U 5      nU(       d  Sn[        U5      e[        U5      S:X  aF  [        US   [        R
                  [        R                  [        R                  45      (       a  US   $ UR                  S5      (       Ga†  [        US   [        R
                  [        R                  45      (       d   U< S[        US   5      < 3n[        U5      e[        [        R                  " S U 5       5      5      n[        [        U5      5       VVs0 s H  u  pxX‡_M	     snnm[        T5      n	[        [!        S [        S U 5       5      5      U4S	 jS
9mT(       d  U< S3n[#        U5      eUS:X  a  SOUR%                  S5      m[!        UU4S jU V
s/ s H  oªR'                  5       PM     sn
5      R)                  TSS9R*                  " U	6 n[        US   [        R
                  5      nU(       a  UR-                  5       $ U$ US   nSSKJn  [        U[        R
                  5      (       Gap  US:X  a!  [3        [4        R6                  " U5      5      nGOöUS:X  a[  [9        [4        R:                  " U V
s/ s H  oªR'                  5       PM     sn
UUSS95      R-                  UR=                  5       S9nGO•US:X  a!  [3        [4        R>                  " U5      5      nGOnUS:X  a[  [9        [4        R@                  " U V
s/ s H  oªR'                  5       PM     sn
UUSS95      R-                  UR=                  5       S9nGOUS:X  a!  [3        [4        RB                  " U5      5      nGOæSRE                  S [G        [H        5       5       5      nSU SU< 3n[        U5      e[        U[        R                  5      (       aÇ  US;   a/  [9        [4        R:                  " UUUURK                  S5      S95      $ US;   a/  [9        [4        R@                  " UUUURK                  S5      S95      $ US:X  a  [9        [4        RL                  " UUS 95      $ SRE                  S! [G        [H        5       5       5      nS"U SU< 3n[        U5      e[        U[        R                  5      (       a3  US:X  a   [O        [4        RP                  " U5      5      nO‚S#n[        U5      e[        U[        RR                  5      (       a;  [U        [4        RV                  " U Vs/ s H  nURX                  PM     snU5      5      $ S$[        U5      < S%3n[        U5      eU(       a  UR[                  5       $ U$ s  snnf s  sn
f s  sn
f s  sn
f s  snf )&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', '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 and fills 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.

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")
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 â”‚
â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
zcannot concat empty listé   r   Úalignz strategy is not supported for c              3  ó@   #   • U  H  oR                  5       v •  M     g 7f©N©Úcollect_schema©Ú.0Úes     ÚiC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\polars/functions/eager.pyÚ	<genexpr>Úconcat.<locals>.<genexpr>¹   s   é € Ð.QÊ5Àa×/?Ñ/?×/AÐ/AÊ5ùó   ‚c                ó0   • [        U 5      [        U5      -  $ r$   )Úset)ÚxÚys     r*   Ú<lambda>Úconcat.<locals>.<lambda>¾   s   € œS ›V¤c¨!£fš_ó    c              3  ó@   #   • U  H  oR                  5       v •  M     g 7fr$   r%   r'   s     r*   r+   r,   ¿   s   é € Ð8²%¨Q×&Ñ&×(Ð(²%ùr-   c                ó(   >• TR                  U S5      $ )Nr   )Úget)ÚkÚkeys    €r*   r2   r3   Á   s   ø€ ˜#Ÿ'™' ! Qœ-r4   )r9   z- strategy requires at least one common columnÚfullÚalign_c                ó*   >• U R                  UTTSSS9$ )NÚ
right_leftT)Úonr   Úmaintain_orderÚcoalesce©Újoin)r0   r1   Úcommon_colsÚjoin_methods     €€r*   r2   r3   Ï   s#   ø€ Ø—F‘FØØ&Ø'Ø'3Ø!%ð ñ r4   T)Úbyr?   ©ÚQueryOptFlagsr   Úvertical_relaxed)r   r   Úto_supertypes©ÚoptimizationsÚdiagonalÚdiagonal_relaxedÚ
horizontalz, c              3  ó8   #   • U  H  n[        U5      v •  M     g 7fr$   ©Úrepr©r(   Úms     r*   r+   r,      ó   é € ÐHÒ1G¨A¤ Q§ Ò1Gùó   ‚z DataFrame `how` must be one of {z}, got )r   rH   Úrelaxed)rL   rM   )r   c              3  ó8   #   • U  H  n[        U5      v •  M     g 7fr$   rP   rR   s     r*   r+   r,     rT   rU   z LazyFrame `how` must be one of {z/Series only supports 'vertical' concat strategyzdid not expect type: z in `concat`).ÚlistÚ
ValueErrorÚlenÚ
isinstanceÚplr   r   r   Ú
startswithr   Ú	TypeErrorr   Úfrom_iterableÚ	enumerater   Úsortedr   r   ÚremoveprefixÚlazyÚsortÚselectÚcollectÚpolars.lazyframe.opt_flagsrG   r   ÚplrÚ	concat_dfr   Ú	concat_lfÚ_eagerÚconcat_df_diagonalÚconcat_lf_diagonalÚconcat_df_horizontalrB   r
   r   ÚendswithÚconcat_lf_horizontalr   Úconcat_seriesr   r   Úconcat_exprÚ_pyexprr   )Úitemsr   r   r   ÚelemsÚmsgÚall_columnsr8   ÚvÚoutput_column_orderÚdfÚlfÚeagerÚfirstrG   ÚoutÚallowedr)   rC   rD   r9   s                     @@@r*   Úconcatr€      sä  ú€ ô^ ‹K€EæØ(ˆÜ˜‹oÐÜ	ˆU‹q‹œZØˆa‰”2—<‘<¤§¡¬B¯L©LÐ9÷ñ ð Q‰xˆà
‡~~g×ÒÜ˜% ™(¤R§\¡\´2·<±<Ð$@×AÑAØ‘GÐ:Ô;NÈuÐUVÉxÓ;XÑ:[Ð\ˆCÜ˜C“.Ð ô œ5×.Ò.Ñ.QÉ5Ó.QÓQÓRˆÜ )¬.¸Ó*EÔ FÔGÒ F™˜ˆqŠtÑ FÒGˆÜ" 3›iÐÜÜÙ,ÜÑ8±%Ó8Ó8óô (ñ
ˆö Ø‘GÐHÐIˆCÜ'¨Ó,Ð,ð
 ˜W“n‰F¨#×*:Ñ*:¸8Ó*Dð 	ô õñ &+Ó+¢U˜r—‘–¡UÑ+ó÷ ‰T[°ˆTÐ6ß‰Vðð )ð*ð 	ô  ˜5 ™8¤R§\¡\Ó2ˆÞ$ˆrz‰z‹|Ð,¨"Ð,ð !‰H€Eå8ä%œŸ™×&Ò&Ø*ÓÜœ#Ÿ-š-¨Ó.Ó/ŠCØÐ&Ó&ÜÜ—’Ù).Ó/ª 2—W‘W–Y©Ñ/Ø#Ø%Ø"&ñ	ó÷ ‰g M×$8Ñ$8Ó$:ˆgÐ;ò ð JÓÜœ#×0Ò0°Ó7Ó8ŠCØÐ&Ó&ÜÜ×&Ò&Ù).Ó/ª 2—W‘W–Y©Ñ/Ø#Ø%Ø"&ñ	ó÷ ‰g M×$8Ñ$8Ó$:ˆgÐ;ò ð LÓ Üœ#×2Ò2°5Ó9Ó:ŠCà—i‘iÑH´¼,Ô1GÓHÓHˆGØ5°g°Y¸hÀsÁgÐNˆCÜ˜S“/Ð!ä	Eœ2Ÿ<™<×	(Ñ	(ØÐ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“/Ð!ä	Eœ2Ÿ9™9×	%Ñ	%Ø*ÓÜœ×*Ò*¨5Ó1Ó2‰CàCˆCÜ˜S“/Ð!ä	Eœ2Ÿ7™7×	#Ñ	#ÜœŸš¹UÓ)CºU¸¨!¯)¬)¹UÑ)CÀWÓMÓNÐNà%Ô&9¸%Ó&@Ñ%CÀ<ÐPˆÜ˜‹nÐæØ{‰{‹}ÐØ€Jùóq Hùò< ,ùò& 0ùò 0ùòh *Ds   ÄU6Æ$U<
ÊVÌVÔ Vr:   )r   Ú
descendingc                óî   ^ ^• [        U5      S:¬  n      S	U U4S jjnSSKJn  [        XS5      S   R	                  T USS9nU(       a+  UR                  UR                  5       S9R                  5       nU$ )
zLCreate a single master frame with all rows aligned on the common key values.éú   c                óF   >• Xsu  p#u  pEXCR                  UTTSU 3SSSS94$ )NÚ:Tr=   )r   r>   ÚsuffixÚnulls_equalr@   r?   rA   )Úidx_xÚidx_yÚ_r0   Úy_idxr1   Úalign_onr   s         €€r*   Ú	join_funcÚ"_alignment_join.<locals>.join_func@  sI   ø€ ð #Ð‰ˆ‘
Ø—f‘fØØØØug;ØØØ'ð ð 
ð 
ð 	
r4   r   rF   r!   T)rE   r   r?   rJ   )rˆ   útuple[int, LazyFrame]r‰   r   Úreturnr   )rZ   Úpolars.lazyframerG   r   rd   rf   Únonerc   )rŒ   r   r   Ú
idx_framesÚpost_align_collectr   rG   Újoineds   ``      r*   Ú_alignment_joinr–   5  s   ù€ ô ˜Z›¨CÑ/Ðð
Ø$ð
à$ð
ð 
÷
ð 
õ /äIÓ*¨1Ñ-×2Ñ2Ø 
¸4ð 3ð €Fö Ø—‘¨m×.@Ñ.@Ó.BÐC×HÑHÓJˆØ€Mr4   )r   re   r   c                óî  • U(       d  / $ [        U5      S:X  a7  [        US   [        R                  [        R                  45      (       d  US   n[        U[
        [        45      (       a  [        U5      n[        U Vs1 s H  n[        U5      iM     sn5      S:w  a  Sn[        U5      e[        US   [        R                  5      n[        U [        5      (       d  [        U [        5      (       d  U /OU n U  Vs/ s H>  n[        U[        R                  5      (       a  UR                  R                  5       OUPM@     n	n[        U5       V
Vs/ s H  u  p«X«R!                  5       4PM     nn
n[#        XÉXS.6n[%        UR'                  5       5      n/ nU H¦  u  n
nSU
 3nUR'                  5        Vs/ s HL  nU U 3U;   a)  [(        R*                  " U U 35      R-                  U5      O[(        R*                  " U5      PMN     nnUR.                  " U6 nUb  UR/                  U5      nUR1                  U5        M¨     U(       a  [(        R2                  " U5      $ U$ s  snf s  snf s  snn
f s  snf )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  â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”˜
r!   r   zJinput frames must be of a consistent type (all LazyFrame or all DataFrame))rŒ   r   r   r…   )rZ   r[   r\   r   r   r   r   ÚtupleÚtyper^   Ústrr   r   ÚmetaÚoutput_namer`   rc   r–   r/   r&   ÚFÚcolÚaliasre   ÚappendÚcollect_all)r>   r   re   r   ÚframesÚfrv   r|   ÚcrŒ   ÚidxÚframer“   Úalignment_frameÚaligned_colsÚaligned_framesr{   ÚsfxÚdf_colss                      r*   Úalign_framesr¬   Y  s,  € öX Øˆ	ä
ˆ6ƒ{aÓ¤
¨6°!©9´r·|±|ÄRÇ\Á\Ð6R× SÑ SØ˜‘ˆÜ&œ9¤hÐ/×0Ñ0Üv“ˆä
™VÓ$šV˜ŒDŽG™VÑ$Ó%¨Ó*àXð 	ô ˜‹nÐäv˜a‘y¤"§,¡,Ó/€EÜ˜R¤×%Ñ%¬Z¸¼H×-EÑ-Eˆ"‰ÈB€BÙQSÓTÒQSÈA¬°A´r·w±w×)?Ñ)?—‘×#Ñ#Ô%ÀQÒFÑQS€HÐTô 9BÀ&Ô8IÔJÒ8I©*¨#3Ÿ
™
›Ó%Ñ8I€JÑJÜ%Ø	¨Cò€Oô
 ×5Ñ5Ó7Ó8€LØ€NÛ‰ˆˆRØ#ˆiˆð ×&Ñ&Ô(ó
â(ð /0¨S°°¨;¸,Ó+FŒAEŠEQC˜u+Ó×$Ñ$ QÔ'ÌAÏEÊEÐRSËHÒTÙ(ð 	ð 
ð ×"Ò" GÐ,ˆØÑØ—‘˜Ó ˆAØ×Ñ˜aÖ ñ ö -2Œ1=Š=˜Ó(ÐE°~ÐEùò? %ùò Uùó Kùò
s   Á?I"Ã<AI'ÅI,Æ6AI2)
rt   zIterable[PolarsType]r   r   r   Úboolr   r­   r   r   )
r“   r   rŒ   z	list[str]r   r   r   úbool | Sequence[bool]r   r   )r¢   zFrameType | Iterable[FrameType]r>   zBstr | Expr | Sequence[str] | Sequence[Expr] | Sequence[str | Expr]r   r   re   z(str | Expr | Sequence[str | Expr] | Noner   r®   r   zlist[FrameType])0Ú
__future__r   Ú
contextlibÚcollections.abcr   r   r   Ú	functoolsr   Ú	itertoolsr   Útypingr	   r
   Úpolars._reexportÚ	_reexportr\   Úpolarsr   r   Úpolars._typingr   Úpolars._utils.variousr   r   Úpolars._utils.wrapr   r   r   r   Úpolars.exceptionsr   ÚsuppressÚImportErrorÚpolars._plrÚ_plrrh   r   r   r   r   r   r   r   r   r€   r–   r¬   © r4   r*   Ú<module>rÁ      s<  ðÝ "ã ß 9Ñ 9Ý Ý ß *å Ý !Ý 'ß Eß CÓ CÝ 3à×Ò˜Õ%Ý÷ &ö Ý(ç9Ó9ßBÑBð #ØØñXØðXð 
ðXð ð	Xð
 ðXð õXð| Ø(-ñ	!Ø&ð!àð!ð 
ð!ð &ð	!ð
 õ!ðN Ø7;Ø(-ñsFØ,ðsFàJðsFð 
ðsFð 5ð	sFð
 &ðsFð ösF÷S
 &Õ%ús   Á'CÃ
C%