
    d                     \    d Z ddlZddlZddlmZ ddlmZmZ ddl	m
Z  G d d          ZdS )z
test_insert is specifically for the DataFrame.insert method; not to be
confused with tests with "insert" in their names that are really testing
__setitem__.
    N)PerformanceWarning)	DataFrameIndexc                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )TestDataFrameInsertc                    t          t          j                            dd          t          j        d          g d          }|                    dd|d                    t          j        |j        t          g d                     t          j
        |d         |d         d	
           |                    dd|d                    t          j        |j        t          g d                     t          j        |d         |d         d	
           t          j        t          d          5  |                    dd|d                    d d d            n# 1 swxY w Y   d}t          j        t          |          5  |                    dd|d                    d d d            n# 1 swxY w Y   d|j        _        |                    dd|d                    |j        j        dk    sJ d S )N      )cba)indexcolumnsr   foor   )r   r   r   r   F)check_names   barr   )r   r   r   r   r   zalready existsmatch   r   zcannot insert c, already exists	some_namebaz)r   nprandomrandnarangeinserttmassert_index_equalr   r   assert_series_equalassert_almost_equalpytestraises
ValueErrornameselfdfmsgs      c/var/www/html/t/fyr/venv311/lib/python3.11/site-packages/pandas/tests/frame/indexing/test_insert.pytest_insertzTestDataFrameInsert.test_insert   sG   IOOAq!!1
 
 
 			!UBsG$$$
bj%0F0F0F*G*GHHH
r#w5	uEEEE
		!UBsG$$$
bj%0M0M0M*N*NOOO
r#w5	uEEEE]:-=>>> 	' 	'IIabg&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 0]:S111 	' 	'IIabg&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' &

		!UBsG$$$z+------s$   2EE #E F..F25F2c                    t          dddgi          }|                    i           }|                    ddddg           |                    i           }t          |           t          ddgddggddg          }t	          j        ||           |                    dd	d
dg           |                    i           }t          |           t          g dg dgg d          }t	          j        ||           d S )Nr   皙?皙@r   r   r   r   r   r   ?ffffff@)r0   r   r-   )r1   r   r.   )r   r   r   )r   renamer   strr   assert_frame_equal)r'   r(   resultexpecteds       r*   test_insert_column_bug_4032z/TestDataFrameInsert.test_insert_column_bug_4032,   s   c3Z())YYrY""
		!S1a&!!!2&&Fq#hC1C:FFF
fh///
		!S3*%%%2&&Fmmm]]];___UUU
fh/////    c                 &   t                      }|                    ddg dd           |                    ddg dd           |                    ddg dd           t          g dg d	g d
gg d          }t          j        ||           d S )Nr   A)ghiT)allow_duplicates)def)r   r   r   )r   r?   r;   )r   r@   r<   )r   rA   r=   )r:   r:   r:   r/   )r   r   r   r4   )r'   r(   exps      r*   test_insert_with_columns_dupsz1TestDataFrameInsert.test_insert_with_columns_dups?   s    [[
		!S///D	AAA
		!S///D	AAA
		!S///D	AAA__ooo?
 
 
 	b#&&&&&r8   c                     t          t          j                            dd                    }|d         }|rd }nt          }t          j        |          5  t          d          D ]}|d         |z  ||dz   <   	 d d d            n# 1 swxY w Y   |r>d|j        d<   |j        d         |d         d         k    sJ |j        d         dk    sJ d S d|j	        d<   |j        d         |d         d         k    sJ |j        d         dk    sJ d S )N   r
   r   d   r   c   )r   r   )
r   r   r   r   r   r   assert_produces_warningrangeilocvalues)r'   using_array_managerusing_copy_on_writer(   serexpected_warningns          r*   test_insert_item_cachez*TestDataFrameInsert.test_insert_item_cacheJ   sq   ryq!,,--e 	2#  2'(899 	& 	&3ZZ & &qEAI1q5		&	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&  	'CHQK74=BqE!H,,,,74=B&&&&&&CJqM74=BqE!H,,,,74=B&&&&&&s   $BBBc                     t          t          j                            ddd          d          }t	          j        d           5  t          j        g d          |d<   d d d            d S # 1 swxY w Y   d S )	Nr   rF   )r
   rF   )sizeInt64)dtype)r   r   r
   r   )r   r   r   randintr   rH   array)r'   r(   s     r*   test_insert_EA_no_warningz-TestDataFrameInsert.test_insert_EA_no_warninga   s     ry((Ch(??wOOO'-- 	* 	*hyyy))BsG	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   A--A14A1c                     t          ddgddgd          }d}t          j        t          |          5  |                    dd|           d d d            d S # 1 swxY w Y   d S )	Nr   r   r
   rE   )col1col2z5Expected a 1D array, got an array with shape \(2, 2\)r   newcol)r   r"   r#   r$   r   r&   s      r*   test_insert_framez%TestDataFrameInsert.test_insert_frameh   s    AA7788F]:S111 	' 	'IIa2&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	's   AA AN)	__name__
__module____qualname__r+   r7   rC   rQ   rX   r]    r8   r*   r   r      sn        . . .20 0 0&	' 	' 	'' ' '.* * *' ' ' ' 'r8   r   )__doc__numpyr   r"   pandas.errorsr   pandasr   r   pandas._testing_testingr   r   ra   r8   r*   <module>rh      s    
      , , , , , ,             \' \' \' \' \' \' \' \' \' \'r8   