a
    é´«jv  ã                   @   s  d dl Zd dlZd dlZd dlmZ d dlmZ ej	 
dddg¡dd„ ƒZej	 
dd	d
g¡dd„ ƒZdd„ Zdd„ Zdd„ Zej	 
dd	d
g¡dd„ ƒZdd„ Zdd„ Zej	 
dejejg¡ej	 
ddd	ideƒ ig¡dd„ ƒƒZd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ ZdS ),é    N)ÚSerieszoperation, expected)ÚminÚa)ÚmaxÚbc                 C   s,   t ddgdd�}t|| ƒƒ }||ks(J ‚d S )Nr   r   Ústring©Údtype)r   Úgetattr)Z	operationÚexpectedÚserZres_operation_serie© r   úb/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/pandas/tests/series/test_reductions.pyÚtest_reductions_series_strings	   s    r   Ú	as_periodTFc                 C   s^   t dd„ tddƒD ƒƒ}| r*|j d¡}n|j d¡}| ¡ }|j|jksNJ ‚t ||¡ d S )Nc                 S   s   g | ]}t  d d|¡‘qS )i»  é   )ÚpdÚ	Timestamp)Ú.0Únr   r   r   Ú
<listcomp>   ó    z-test_mode_extension_dtype.<locals>.<listcomp>é   é   ÚDz
US/Central)	r   ÚrangeÚdtZ	to_periodZtz_localizeÚmoder	   ÚtmÚassert_series_equal)r   r   Úresr   r   r   Útest_mode_extension_dtype   s    r!   c                 C   sÐ   t dddtjddtjg| d�}|jdd�}t ddtjg| d�}t ||¡ |jdd�}t ddg| d�}t ||¡ tj|d< |jdd�}t ddg| d�}t ||¡ |jdd�}t tjg| d�}t ||¡ d S )	Nr   é   é   r   F)ZdropnaTéÿÿÿÿ)r   r   ZNAr   r   r   )Zany_numeric_ea_dtyper   Úresultr   r   r   r   Útest_mode_nullable_dtype    s    
r&   c                  C   sn   t  d¡ tddgtd�} t dd¡� |  ¡ }W d   ƒ n1 sD0    Y  tddgtd�}t ||¡ d S )NZpyarrowr   r   r   zfuture.infer_stringT)	ÚpytestZimportorskipr   Úobjectr   Zoption_contextr   r   r   )r   r%   r   r   r   r   Útest_mode_infer_string6   s    
&r)   c                  C   sN   t dtjgdd�} | d }|  ¡ |ks*J ‚|  ¡ |ks:J ‚|  ¡ |ksJJ ‚d S )Nr   zm8[ns]r   )r   r   ZNaTÚmedianr   r   )r   Úexpr   r   r   Útest_reductions_td64_with_nat@   s
    r,   Úskipnac                 C   s>   t g dd�}|j| d�}t|tjƒs(J ‚|t d¡ks:J ‚d S )Nztimedelta64[ns]r   )r-   r   )r   ÚsumÚ
isinstancer   Ú	Timedelta)r-   r   r%   r   r   r   Útest_td64_sum_emptyI   s    r1   c                  C   s(  t tjdddd�ƒ} | d  t d¡7  < | |  ¡   ¡ }t t | |  ¡  ¡jt| ƒ  	¡ ¡}t
 |jd |jd ¡s|J ‚d}tjt|d	��  | |  ¡   	¡  W d   ƒ n1 s´0    Y  | dd
… }tjt|d	��  || ¡   	¡  W d   ƒ n1 sþ0    Y  | dd… }|| ¡   	¡  d S )NZ20130101i † Úh)ZperiodsÚfreqr   z1s 1msiè  zoverflow in timedelta operation©Úmatchi'  )r   r   Z
date_ranger0   r   ÚmeanZTimedeltaIndexZasi8Úlenr.   ÚnpZallcloseÚ_valuer'   ÚraisesÚ
ValueError)r   r%   r   ÚmsgÚs1Ús2r   r   r   Útest_td64_summation_overflowS   s    &..r?   c                  C   s.   t g d¢tdƒd�} |  ¡ }t|t ƒr*J ‚d S )N)ç      ð?r@   r@   r"   )Úindex)r   r   Úprodr/   )r   r%   r   r   r   Útest_prod_numpy16_bugl   s    rC   ÚfuncÚkwargsÚkeepdimsÚoutc                 C   sr   t ddgƒ}tt| ƒƒ}|j}d|› d|› d�}tjt|d��  ||fi | ¤Ž W d   ƒ n1 sd0    Y  d S )Nr   r#   zthe 'z=' parameter is not supported in the pandas implementation of z\(\)r4   )r   ÚnextÚiterÚ__name__r'   r:   r;   )rE   rD   r   ÚparamÚnamer<   r   r   r   Ú)test_validate_any_all_out_keepdims_raisess   s    þÿrM   c                  C   sP   t ddgƒ} d}tjt|d�� tj| dd� W d   ƒ n1 sB0    Y  d S )Nr   r#   zPthe 'initial' parameter is not supported in the pandas implementation of sum\(\)r4   é
   )Úinitial©r   r'   r:   r;   r8   r.   ©r   r<   r   r   r   Útest_validate_sum_initialƒ   s
    ÿrR   c                  C   sN   t ddgƒ} d}tjt|d�� | jdd� W d   ƒ n1 s@0    Y  d S )Nr   r#   z[the 'overwrite_input' parameter is not supported in the pandas implementation of median\(\)r4   T)Zoverwrite_input)r   r'   r:   r;   r*   rQ   r   r   r   Útest_validate_median_initialŽ   s
    ÿrS   c                  C   sP   t ddgƒ} d}tjt|d�� tj| dd� W d   ƒ n1 sB0    Y  d S )Nr   r#   zQthe 'keepdims' parameter is not supported in the pandas implementation of sum\(\)r4   T)rF   rP   rQ   r   r   r   Útest_validate_stat_keepdims›   s
    ÿrT   c                 C   s    t ddgƒ}| ¡ dksJ ‚d}tjt|d�� | ¡  W d   ƒ n1 sL0    Y  | ¡ }| sfd}tjt|d�� | ¡  W d   ƒ n1 s’0    Y  d S )NÚ1Ú2Z12zHCould not convert string '12' to numeric|does not support|Cannot performr4   zECould not convert \['12'\] to numeric|does not support|Cannot perform)r   r.   r'   r:   Ú	TypeErrorr6   Úto_frame)Úusing_array_managerZusing_infer_stringr   r<   Údfr   r   r   Ú(test_mean_with_convertible_string_raises¦   s    &r[   c                 C   s  t  dddœg¡}| rd}nd}tjt|d�� | ¡  W d   ƒ n1 sL0    Y  tjt|d�� | d¡ W d   ƒ n1 s„0    Y  d}tjt|d�� |d	  ¡  W d   ƒ n1 sÂ0    Y  d
}tjt|d��& t |d	  d¡j	¡ W d   ƒ n1 �s0    Y  d S )NÚJé{   )ÚdbÚnumericz'Could not convert string 'J' to numericzDCould not convert \['J'\] to numeric|does not support|Cannot performr4   r6   zGCould not convert string 'J' to numeric|does not support|Cannot performr^   zECould not convert string 'J' to numeric|ufunc 'divide'|Cannot performr   )
r   Z	DataFramer'   r:   rW   r6   Zaggr8   ZastypeÚarray)rY   rZ   r<   r   r   r   Ú#test_mean_dont_convert_j_to_complex¶   s    &(*ra   c                 C   s�   d}t g d¢ƒ}tjt|d�� | ¡  W d   ƒ n1 s<0    Y  | sNd}| ¡ }tjt|d�� | ¡  W d   ƒ n1 s‚0    Y  d S )NzICannot convert \['1' '2' '3'\] to numeric|does not support|Cannot perform)rU   rV   Ú3r4   zMCannot convert \[\['1' '2' '3'\]\] to numeric|does not support|Cannot perform)r   r'   r:   rW   r*   rX   )rY   r<   r   rZ   r   r   r   Ú*test_median_with_convertible_string_raisesË   s    &ÿrc   )Únumpyr8   r'   Zpandasr   r   Zpandas._testingZ_testingr   ÚmarkZparametrizer   r!   r&   r)   r,   r1   r?   rC   ÚanyÚallr(   rM   rR   rS   rT   r[   ra   rc   r   r   r   r   Ú<module>   s0   


	
	