
    .ib'                     X    d dl Zd dlZd dlZd dlmZmZmZmZm	Z	 d dl
mZ  G d d      Zy)    N)	DataFrame
RangeIndexSeriesconcat
date_rangec                   D   e Zd Zd Zd Zej                  j                  dddg      ej                  j                  dg g dg      d               Zej                  j                  d	e	j                  e	j                  e	j                  fe	j                  e	j                  e	j                  fd
e	j                  e	j                  fd
e	j                  e	j                  fde	j                  e	j                  fde	j                  e	j                  fddg      d        Zej                  j                  dg d      d        Zej                  j                  dg d      ej                  j                  dg d      d               Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)TestEmptyConcatc                 $   t        t        j                  j                  d      j	                  d      t        d            }|d d j                         }d|d<   |dd }||||dd  g}t        |d|	      }|j                  g d
      }|d   j                  |st        nd      |d<   d|j                  dddf<   t        j                  ||       t        dt        d      it        ddd            }t               }t        ||gd      }	t        j                  |	|       t        ||gd      }	t        j                  |	|       t        ||g      }	t        j                  |	|       t        ||g      }	t        j                  |	|       y )N   )
      abcdcolumns   barfoor   )axissort)abcdr   strr   Ai'  20130101s)periodsfreqindex   r   )r   nprandomdefault_rngstandard_normallistcopyr   reindexastypeobjectloctmassert_frame_equalranger   )
selfr   using_infer_stringdfdfcopyemptyframes	concattedexpectedresults
             d/var/www/app/trading-bot/venv/lib/python3.12/site-packages/pandas/tests/reshape/concat/test_empty.pytest_handle_empty_objectsz)TestEmptyConcat.test_handle_empty_objects   sy   II!!!$44W=tF|
 BQu1Q%12/65	::&A:B"5/00,F%
 $)QqS%Z 
i2 %,z*eRU'V
 U!,
fb)!,
fb)U$
fb)$
fb)    c                    t        g dd      }t        dd      }t        ||gd      }t        g dt        j                  t        j                  t        j                  gd	t        d
            }t        j                  ||       t        g dd      }t        dd      }t        ||gd      }t        g dd      }t        j                  ||       t        g dd      }t        d d      }t        ||gd      }t        g dt        j                  t        j                  t        j                  gdddgt        d
            }t        j                  ||       y )Nr"   r      x)nameyfloat64)rA   dtyper"   r#   )r@   rB   r?   r    r   rD   )r@   r   )r   r!   )	r   r   r   r$   nanr   r.   r/   assert_series_equal)r1   s1s2resexps        r:   test_concat_empty_seriesz(TestEmptyConcat.test_concat_empty_series4   s   IC(I.b"XA&266266266":;Q-
 	c3'IC(I.b"XA&Yi0
sC( IC(Y/b"XA& 89!HQ-

 	c3'r<   tzNUTCvaluesr>   c                 v   t        g d      j                  j                  |      }|rd nt        j                  }t        ||      }t        t        t        j                  gt        |      z  d      j                  j                  |      |d      }t        ||gd      }t        j                  ||       y )NM8[ns]rE   )r   r"   r"   r#   )r   dttz_localizer$   rC   r   pdNaTlenr   r.   r/   )r1   rM   rO   firstrD   secondr8   r9   s           r:   !test_concat_empty_series_timelikez1TestEmptyConcat.test_concat_empty_series_timelikeQ   s    
 r*--99"=BJJe,266(S[0ADDPPQST
 a0
fh/r<   zleft,right,expectedm8[ns]rQ   )categoryr[   r[   )r[   r,   r,   c                 h    t        t        |      t        |      g      }|j                  |k(  sJ y NrE   )r   r   rD   )r1   leftrightr8   r9   s        r:   test_concat_empty_series_dtypesz/TestEmptyConcat.test_concat_empty_series_dtypesc   s/    $ d+V%-@AB||x'''r<   rD   )rC   int8uint8boolrZ   rQ   c                     t        j                  |      }t        t        |      g      }|j                  |k(  sJ t        t        |      t        |      g      }|j                  |k(  sJ y r]   )r$   rD   r   r   )r1   rD   r9   s      r:   0test_concat_empty_series_dtypes_match_roundtripsz@TestEmptyConcat.test_concat_empty_series_dtypes_match_roundtripsx   s`     e,-.||u$$$e,f5.ABC||u$$$r<   )rC   ra   rb   rZ   rQ   dtype2c                 2   ||k(  rt        j                  d       d d fd}t        j                  |      }t        j                  |      } |||      }t	        t        |      t        |      g      j                  }|j                  |k(  sJ y )Nz%same dtype is not applicable for testc                     | j                   |j                   h}t        |h dz
        s| j                   dk(  s|j                   dk(  ryt        |ddhz
        s| j                   dk(  s|j                   dk(  ryy )N>   r   iuri   rj   r   kindrV   rD   rf   typss      r:   int_result_typezSTestEmptyConcat.test_concat_empty_series_dtypes_roundtrips.<locals>.int_result_type   si    JJ,Dto-.

c!V[[C%7c
*+

c!V[[C%7r<   c                     | j                   |j                   h}t        |h dz
        s| j                   dk(  s|j                   dk(  ryy )N>   fri   rj   rq   rk   rm   s      r:   float_result_typezUTestEmptyConcat.test_concat_empty_series_dtypes_roundtrips.<locals>.float_result_type   s>    JJ,Dto-.

c!V[[C%7r<   c                 :     | |      }||S  | |      }||S y)NO )rD   rf   r9   rr   ro   s      r:   get_result_typezSTestEmptyConcat.test_concat_empty_series_dtypes_roundtrips.<locals>.get_result_type   s4    &uf5F!$UF3F!r<   rE   )pytestskipr$   rD   r   r   rl   )r1   rD   rf   rv   r8   r9   rr   ro   s         @@r:   *test_concat_empty_series_dtypes_roundtripsz:TestEmptyConcat.test_concat_empty_series_dtypes_roundtrips   s     F?KK?@
			 &!"5&1e,f6.BCDJJ{{h&&&r<   c                     t        t        d      t        t        j                        t        t        j                        g      j
                  t        j                  k(  sJ y )NrQ   rE   )r   r   r$   bool_int64rD   object_r1   s    r:   &test_concat_empty_series_dtypes_triplez6TestEmptyConcat.test_concat_empty_series_dtypes_triple   sF    h'bhh)?bhhAWXezz	
r<   c                     t        t        t        j                  g       d      t        d      g      j                  dk(  sJ y )Nr[   rE   rC   )r   r   r$   arrayrD   r~   s    r:   2test_concat_empty_series_dtype_category_with_arrayzBTestEmptyConcat.test_concat_empty_series_dtype_category_with_array   s?     J7i9PQe	
r<   c                    t        t        d      j                  d      t        d      j                  d      g      }|j                  dk(  sJ t        t        d      j                  d      t        d      g      }t	        j
                  t        j                        }|j                  |k(  sJ t        t        d      j                  d      t        d      g      }t	        j
                  d      }|j                  |k(  sJ y )NrC   rE   SparsezSparse[float64]r,   )r   r   r+   rD   rT   SparseDtyper$   rC   )r1   r9   r8   s      r:   &test_concat_empty_series_dtypes_sparsez6TestEmptyConcat.test_concat_empty_series_dtypes_sparse   s    Y'..x8Y'..x8
 ||0000)$++H5vI7NO
 >>"**-||x''')$++H5vH7MN
 >>(+||x'''r<   c                     t        g dt        j                  g dd      }t        |j                        }t	        ||gd      }|j                  t              }t        j                  ||       y )N)r   r"   r"   r>   )RowEmptyCol	NumberColr   r   r#   )	r   r$   rF   r   r   r+   r,   r.   r/   )r1   df_1df_2r9   r8   s        r:   !test_concat_empty_df_object_dtypez1TestEmptyConcat.test_concat_empty_df_object_dtype   sS    YWX.t1-;;v&
fh/r<   c                    t        t        d            }|d   j                  t        j                        |d<   |d   j                  t        j
                        |d<   |d   j                  t        j                        |d<   t        ||g      }|d   j                  t        j                  k(  sJ |d   j                  t        j
                  k(  sJ |d   j                  t        j                  k(  sJ t        ||j                  t        j                        g      }|d   j                  t        j                  k(  sJ |d   j                  t        j                  k(  sJ |d   j                  t        j                  k(  sJ y )Nabcr   r   r   r   )
r   r(   r+   r$   r{   int32rC   r   rD   r}   )r1   r3   r9   s      r:   "test_concat_empty_dataframe_dtypesz2TestEmptyConcat.test_concat_empty_dataframe_dtypes   s0   tE{+S'..*3S'..*3S'..,3R!c{  BHH,,,c{  BHH,,,c{  BJJ...RYYrzz234c{  BJJ...c{  BJJ...c{  BJJ...r<   c                 
   t               }t        dddgiddgd      }t        dg it        d      d      }t        ||gdd      }t        j                  ||       t        ||gdd	      }t        j                  ||       y )
Nr   r"   r   r   r|   )r!   rD   inner)r   joinouter)r   r   r   r.   r/   )r1   df_emptydf_adf_expectedr9   s        r:   test_concat_inner_join_emptyz,TestEmptyConcat.test_concat_inner_join_empty   s    ;#1vq!fGDb	AgNx(qw?
fk2x(qw?
fd+r<   c                     t        dd gdd ggddg      }t        dd gdd ggddg      }t        ||g      }|j                  }t        j                  |j                  |       y )Nr"   r   r   r   )datar   r?   r   )r   r   dtypesr.   rG   )r1   df1df2r9   r8   s        r:   test_empty_dtype_coercez'TestEmptyConcat.test_empty_dtype_coerce   si     q$i!T3c3ZHq$i!T3c3ZHc
#::
v}}h7r<   c                 8   t        ddg      }t        ddg      }t        |||g      }t        g d      }t        j                  ||       t        ddg      }t        dg      }t        ||g      }t        ddg      }t        j                  ||       y )Nr   r   r   r   r   r   r   )r   r   r.   r/   )r1   r   r   r9   r8   df3df4s          r:   test_concat_empty_dataframez+TestEmptyConcat.test_concat_empty_dataframe  s    c
+c
+c3(_5
fh/c
+&c
#c3Z0
fh/r<   c                     t        g dg dd      }t        dg di      }t        |d d |d d g      }|d   j                  t        j                  k(  sJ |s"|d   j                  t        j
                  k(  sJ y y )Nr>   r   )r   r   r   r   r   )r   r   rD   r$   r|   r}   )r1   r2   r   r   r9   s        r:   ,test_concat_empty_dataframe_different_dtypesz<TestEmptyConcat.test_concat_empty_dataframe_different_dtypes  sz    io>?i()Ra#bq'*+c{  BHH,,,6Hvc{  BJJ.SSe.r<   c                 >   t        dt        j                  g t        j                               i      }t        dt        j                  g dt        j                               i      }|j	                         }t        ||g      }t        j                  ||       y)z<48510 `concat` to an empty EA should maintain type EA dtype.r   rE   r>   N)r   rT   r   
Int64Dtyper)   r   r.   r/   )r1   r   df_newr8   r9   s        r:   test_concat_to_empty_eaz'TestEmptyConcat.test_concat_to_empty_ea  sl    c288Bbmmo#FGHC)2==?!KLM;;=6*+
fh/r<   )__name__
__module____qualname__r;   rL   rw   markparametrizerY   r$   r{   r   r}   float32r|   r`   re   ry   r   r   r   r   r   r   r   r   r   r   ru   r<   r:   r	   r	      s   "*H(: [[TD%=1[[XI70 8 20  [[ XXrxx,XXrzz2::.rxx,rxx,rxx,rxx,0,	
 (! (
 [[I%% [[W&VW[[8&'	 X
&'P

(*0/ 
,80T0r<   r	   )numpyr$   rw   pandasrT   r   r   r   r   r   pandas._testing_testingr.   r	   ru   r<   r:   <module>r      s)        V0 V0r<   