o
    d&                     @   s   d dl Z d dlZd dlZd dlZd dlmZ d dlZd dlm	Z	m
Z
mZmZ d dlmZ G dd dZejdeeegdd ZdS )	    N)
skip_if_no)	DataFrameIndexSeries
date_rangec                   @   s  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zej	
dededeg dd ededededededededdgedd edD ejeddejeg ddgdd Zej	
deededggdd Zdd Zd d! Zd"d# Z d$d% Z!d&d' Z"d(d) Z#d*d+ Z$ej	
d,d-egd.d/ Z%ej	
d,d0d1gd2d3 Z&d4d5 Z'e(d6d7d8 Z)d9d: Z*ej	
d;g d<d=d> Z+d?d@ Z,dAdB Z-ej	
dCg dDej	
d,e.e/e0egdEdF Z1d0S )GTestSeriesMiscc                 C   s@   t td}dt|v sJ dt|vsJ dt|vsJ d S )Nabcdstrdtcatr   listdirselfs r   a/var/www/html/visualizacion-main/env/lib/python3.10/site-packages/pandas/tests/series/test_api.pytest_tab_completion   s   z"TestSeriesMisc.test_tab_completionc                 C   sD   t tddd}dt|v sJ dt|vsJ dt|vs J d S )N1/1/2015   periodsr
   r	   r   )r   r   r   r   r   r   r   test_tab_completion_dt   s   z%TestSeriesMisc.test_tab_completion_dtc                 C   sD   t tddd}dt|v sJ dt|v sJ dt|vs J d S )Nabbcdcategorydtyper   r	   r
   r   r   r   r   r   test_tab_completion_cat#   s   z&TestSeriesMisc.test_tab_completion_catc                 C   sJ   t tdddd}dt|v sJ dt|vsJ dt|v s#J d S )Nr   r   r   r   r   r	   r
   )r   r   astyper   r   r   r   r   test_tab_completion_cat_str+   s   z*TestSeriesMisc.test_tab_completion_cat_strc                 C   sJ   g d}t tdd}tdd |j D }t|tt| d S )N)
categoriescodesorderedset_categoriesadd_categoriesremove_categoriesrename_categoriesreorder_categoriesremove_unused_categories
as_orderedas_unorderedaabbcder   c                 S   s   h | ]	}| d s|qS )_)
startswith).0rr   r   r   	<setcomp>C   s    zFTestSeriesMisc.test_tab_completion_with_categorical.<locals>.<setcomp>)	r   r   r   sortedr   __dir__tmassert_almost_equalset)r   
ok_for_catr   resultsr   r   r   $test_tab_completion_with_categorical2   s   z3TestSeriesMisc.test_tab_completion_with_categoricalindex
   )foobarbaz   TFc                 C   s   g | ]}d | qS )ar   )r/   ir   r   r   
<listcomp>T   s    zTestSeriesMisc.<listcomp>e   ABCDEFGH)r      r?      c                 C   sh   t |td}t|}t|jjddD ]\}}|dk r+t|tr*| r*||v s*J q||vs1J qd S )Nr:   r   r   )leveld   )	r   objectr   	enumerater:   unique
isinstancer	   isidentifier)r   r:   r   dir_srA   xr   r   r   test_index_tab_completionF   s   z(TestSeriesMisc.test_index_tab_completionserr   rF   c                 C   s@   d}t jt|d t| W d    d S 1 sw   Y  d S )Nzunhashable type: 'Series'match)pytestraises	TypeErrorhashr   rS   msgr   r   r   test_not_hashablec   s   
"z TestSeriesMisc.test_not_hashablec                 C   s   t |j| d S N)r4   assert_contains_allr:   )r   datetime_seriesr   r   r   test_containsi   s   zTestSeriesMisc.test_containsc                 C   sj   t ddtjg}t|jdd|jdd | ddks!J |ddks*J |ddks3J d S )NrF   r?   rows)axisr:   rG   r   )	r   npnanr4   assert_series_equaldropnasum_get_axis_number_get_axis_namer   r   r   r   test_axis_aliasl   s
   zTestSeriesMisc.test_axis_aliasc                 C   s   t tjsJ d S r]   )pydocgetdocr   r:   )r   r   r   r   test_class_axiss   s   zTestSeriesMisc.test_class_axisc                 C   sN   t tjddg dtdddd}dd }||}| }t|| d S )	Ni  rG   )ABCz1/1/2000r   )columnsr:   c                 S   s   | |    S r]   )idxmax)rQ   r   r   r   f   s   z-TestSeriesMisc.test_ndarray_compat.<locals>.f)	r   rc   randomrandnr   applymaxr4   re   )r   tsdfrs   resultexpectedr   r   r   test_ndarray_compatx   s   

z"TestSeriesMisc.test_ndarray_compatc                 C   s@   t tjd}t t|}t dtddd}t|| d S )Nr;   rF   float64rH   )r   rc   rt   ru   	ones_likeranger4   re   )r   r   ry   rz   r   r   r   test_ndarray_compat_like_func   s   z,TestSeriesMisc.test_ndarray_compat_like_funcc                 C   s2   t tjd}t|jdd|jjdd d S )Nr;   F)order)r   rc   rt   ru   r4   r5   ravelvaluesr   r   r   r   test_ndarray_compat_ravel   s   "z(TestSeriesMisc.test_ndarray_compat_ravelc                 C   s   t td}|js
J d S )Nr   )r   rK   empty)r   s_emptyr   r   r   test_empty_method   s   
z TestSeriesMisc.test_empty_methodr   int64c                 C   s   t dg|d}|jrJ d S )NrF   rH   )r   r   )r   r   full_seriesr   r   r   test_empty_method_full_series   s   z,TestSeriesMisc.test_empty_method_full_seriesNInt64c                 C   s"   t td|d}|jdksJ d S )N	   r   )r   r~   size)r   r   r   r   r   r   test_integer_series_size   s   z'TestSeriesMisc.test_integer_series_sizec                 C   sF   t ddgdd}|ji ksJ d|jd< |d }|jddiks!J d S )Nr   rF   abc)nameversion)r   attrs)r   r   ry   r   r   r   
test_attrs   s
   
zTestSeriesMisc.test_attrsjinja2c                 C   sH   t td}tjd dd t| W d    d S 1 sw   Y  d S )Nr   F)check_stacklevel)r   rK   r4   assert_produces_warninginspect
getmembersr   rS   r   r   r   test_inspect_getmembers   s   
"z&TestSeriesMisc.test_inspect_getmembersc                 C   sr   t jdddd}ttjjdd|d}d|jvsJ d}tjt	|d	 |j
 W d    d S 1 s2w   Y  d S )
Nr   r;   1s)startr   freq)r   )r:   r<   z&'Series' object has no attribute 'foo'rT   )pdtimedelta_ranger   rc   rt   normal__dict__rV   rW   AttributeErrorr<   )r   tdirS   r[   r   r   r   test_unknown_attribute   s   "z%TestSeriesMisc.test_unknown_attributeop)yeardaysecondweekdayc                 C   sJ   d| d}t jt|d t|| W d    d S 1 sw   Y  d S )Nz"'Series' object has no attribute ''rT   )rV   rW   r   getattr)r   r   r_   r[   r   r   r   &test_datetime_series_no_datelike_attrs   s   "z5TestSeriesMisc.test_datetime_series_no_datelike_attrsc                 C   s>   t dddd}|jdksJ |jdksJ |jdksJ d S )N  rF   r;   r   monthr   )r   r   r   r   r   r   r   r   )test_series_datetimelike_attribute_access   s   z8TestSeriesMisc.test_series_datetimelike_attribute_accessc                 C   sN   t dddd}d}tjt|d |j W d    d S 1 s w   Y  d S )Nr   rF   r;   r   z*'Series' object has no attribute 'weekday'rT   )r   rV   rW   r   r   rZ   r   r   r   1test_series_datetimelike_attribute_access_invalid   s
   "z@TestSeriesMisc.test_series_datetimelike_attribute_access_invalidzkernel, has_numeric_only)$)skewT)varT)allF)prodT)anyF)idxminF)quantileF)rr   F)minT)semT)meanT)nuniqueF)rw   T)rg   T)countF)medianT)stdT)backfillF)rankT)
pct_changeF)cummaxF)shiftF)diffF)cumsumF)cumminF)cumprodF)fillnaF)ffillF)padF)bfillF)sampleF)tailF)takeF)headF)covF)corrFc           
      C   s~  t g d|d}|dkr|f}n7|dkr|f}n/|dkr |f}n'|dkr'd}n |dkr.d	}n|dkr5d
}n|dkr>dgf}n	|dkrEd}nd}t||}|sqd}tjt|d ||ddi W d    d S 1 sjw   Y  d S |tu rd| d}tjt|d ||ddi W d    d S 1 sw   Y  d S ||ddi}||ddi}	t|	t rt||	 d S ||	ksJ d S )N)r   rF   rF   r   corrwithr   r   nth)r   r   )T)r   r   r   r   )g      ?r   zP(got an unexpected keyword argument 'numeric_only'|too many arguments passed in)rT   numeric_onlyTzSeries.z2 does not allow numeric_only=True with non-numericF)	r   r   rV   rW   rX   rK   rN   r4   re   )
r   kernelhas_numeric_onlyr   rS   argsmethodr[   ry   rz   r   r   r   test_numeric_only   sF   ,

""
z TestSeriesMisc.test_numeric_only)2__name__
__module____qualname__r   r   r   r    r9   rV   markparametrizer4   makeStringIndexmakeCategoricalIndexr   makeDateIndexmakePeriodIndexmakeTimedeltaIndexmakeIntIndexmakeUIntIndexmakeFloatIndexr~   r   
MultiIndexfrom_tuplesziprR   r   rK   r\   r`   rj   rm   r{   r   r   r   r   r   r   r   r   r   r   r   r   boolintfloatr   r   r   r   r   r      sh    






	
)r   	converterc                 C   sJ   t t | tdg| dksJ W d    d S 1 sw   Y  d S )NrF   )r4   r   FutureWarningr   )r   r   r   r   test_float_int_deprecated#  s   "r   )r   rk   numpyrc   rV   pandas.util._test_decoratorsr   pandasr   r   r   r   r   pandas._testing_testingr4   r   r   r   r   r   complexr   r   r   r   r   <module>   s      