
    Owg(                     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   zstring[pyarrow_numpy]r   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
             ]/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/tests/reshape/concat/test_empty.pytest_handle_empty_objectsz)TestEmptyConcat.test_handle_empty_objects   sz   II!!!$44W=tF|
 BQu1Q%12/65	::&A:B"5/00,F2I
 $)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      }d}t        j                  t        |      5  t        ||gd      }d d d        t        g 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 # 1 sw Y   xY w)Nr!   r      x)nameyfloat64)r@   dtyper!   r"   )r?   rA   r>   r   zDThe behavior of array concatenation with empty entries is deprecated)matchr   )r?   r   )r   r    )r   r   r   r#   nanr   r-   r.   assert_produces_warningFutureWarningassert_series_equal)r0   s1s2resexpmsgs         r9   test_concat_empty_seriesz(TestEmptyConcat.test_concat_empty_series4   sE   IC(I.b"XA&266266266":;Q-
 	c3'IC(I.T''SA 	+"b*C	+ Y
sC( IC(Y/b"XA& 89!HQ-

 	c3'	+ 	+s   FF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]rC   )r   r!   r!   r"   )r   dttz_localizer#   rB   r   pdNaTlenr   r-   r.   )r0   rO   rQ   firstrC   secondr7   r8   s           r9   !test_concat_empty_series_timelikez1TestEmptyConcat.test_concat_empty_series_timelikeS   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]rS   )categoryr^   r^   )r^   r+   r+   c                 h    t        t        |      t        |      g      }|j                  |k(  sJ y NrT   )r   r   rC   )r0   leftrightr7   r8   s        r9   test_concat_empty_series_dtypesz/TestEmptyConcat.test_concat_empty_series_dtypese   s/    $ d+V%-@AB||x'''r;   rC   )rB   int8uint8boolr]   rS   c                     t        j                  |      }t        t        |      g      }|j                  |k(  sJ t        t        |      t        |      g      }|j                  |k(  sJ y r`   )r#   rC   r   r   )r0   rC   r8   s      r9   0test_concat_empty_series_dtypes_match_roundtripsz@TestEmptyConcat.test_concat_empty_series_dtypes_match_roundtripsz   s`     e,-.||u$$$e,f5.ABC||u$$$r;   )rB   rd   re   r]   rS   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url   rm   r   kindrY   rC   ri   typss      r9   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>   frl   rm   rt   rn   rp   s      r9   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 )rC   ri   r8   ru   rr   s      r9   get_result_typezSTestEmptyConcat.test_concat_empty_series_dtypes_roundtrips.<locals>.get_result_type   s4    &uf5F!$UF3F!r;   rT   )pytestskipr#   rC   r   r   ro   )r0   rC   ri   ry   r7   r8   ru   rr   s         @@r9   *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 )NrS   rT   )r   r   r#   bool_int64rC   object_r0   s    r9   &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^   rT   rB   )r   r   r#   arrayrC   r   s    r9   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 )NrB   rT   SparsezSparse[float64]r+   )r   r   r*   rC   rW   SparseDtyper#   rB   )r0   r8   r7   s      r9   &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#   rE   r   r   r*   r+   r-   r.   )r0   df_1df_2r8   r7   s        r9   !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~   int32rB   r   rC   r   )r0   r2   r8   s      r9   "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    rC   inner)r   joinouter)r   r   r   r-   r.   )r0   df_emptydf_adf_expectedr8   s        r9   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-   rH   )r0   df1df2r8   r7   s        r9   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.   )r0   r   r   r8   r7   df3df4s          r9   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   rC   r#   r   r   )r0   r1   r   r   r8   s        r9   ,test_concat_empty_dataframe_different_dtypesz<TestEmptyConcat.test_concat_empty_dataframe_different_dtypes  sz    io>?i()Ra#bq'*+c{  BHH,,,6Hvc{  BJJ.VVh.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   rT   r=   N)r   rW   r   
Int64Dtyper(   r   r-   r.   )r0   r   df_newr7   r8   s        r9   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:   rN   rz   markparametrizer\   r#   r~   r   r   float32r   rc   rh   r|   r   r   r   r   r   r   r   r   r   r   rx   r;   r9   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W0r;   r	   )numpyr#   rz   pandasrW   r   r   r   r   r   pandas._testing_testingr-   r	   rx   r;   r9   <module>r      s)        X0 X0r;   