U
    sVc                  y   @  sP	  U d dl mZ d dlZd dlmZ d dlmZ d dlZd dlZd dlZd dl	Z	d dl
mZ d dlmZmZmZmZmZ d dlZd dlZd dlmZmZmZ d dlmZ d d	lmZ d d
lmZmZm Z m!Z!m"Z" d dl#Z$d dl#m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. d dl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 d dl6m7Z7m8Z8m9Z9 d dl:m;Z;m<Z< d dl=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZT d dlUmVZVmWZW d dlXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z` d dlambZbmcZcmdZdmeZe d dlfmgZgmhZhmiZi d dljmkZk d dllmmZm er@d dl#mnZnmoZo dZpdZqddddgZrdesd< dd d!d"gZtdesd#< eud$d%d&d'gZvdesd(< d)d*d+d,gZwdesd-< erev Zxetew Zyezd.d/gZ{desd0< d1d2gZ|desd3< e}d4d5gZ~desd6< ed7d8gZdesd9< d:d;gZdesd<< d=d>gZdesd?< ed@gZdesdA< edBgZdesdC< edDgZdesdE< e{ex Zee~ e e e e e e ZejejejejejejejejgZdFdGdHe Zdeje$jezdIe$jedJgZdKdL ejejfD Zesd dlZe e e e gZe e e e gZee Ze e gZe	 e gZedMedNedOedPgZe e gZdQdL dRD ZdSdL dRD Ze gZee e e e e e ZedTZeefZdUdVdWdXZdUdVdYdZZe  dUdVd[d\Zd@dVd]d^Zdd`daZdbdc Zd7dVdddeZd dgdVdhdiZd!dkdVdldmZd"dndVdodpZd#dgdVdqdrZd$dsdVdtduZd%dvdVdwdxZÐd&dydVdzd{ZĐd'd|dVd}d~ZŐd(ddVddZƐd)dddddZǐd*dddddZȐd+dddddZɐd,ddZdd Zːd-dddddZdejfddVddZ͐d.ddVddZΐd/ddVddZϐd0ddVddZddVddZѐd1ddVddZҐd2ddVddZӐd3ddVddZԐd4ddVddZՐd5ddVddZddVddZdd ZddVddZِd6ddVddZڐd7ddgdddZېd8ddVddZܐd9ddZݐd:ddVddZG ddĄ de-ZG ddƄ de'ZG ddȄ de%Zd;ddʄZdd7d̜dd΄ZdddќddӄZe$jjj ZddՄ Zd7ddלddلZddۄ Zdd݄ Zdd߄ Zdd Zdd Zdd Zd@dVddZdddddddddddddddddddddddddd ddddAdadCddd6dd<ddddd	d
d^dd3d0dedՐddېddddddddddddrdmdddddddpdxddddudddddd~diddddd{ddddddEdddd\dZdddddݐddXddd-d(d9dddd?dcd#ddddgyZdS (<      )annotationsN)datetime)Decimal)	byteorder)TYPE_CHECKINGCallableContextManagerCounterIterable)can_set_localeget_locales
set_locale)Dtype)pa_version_under1p01)is_float_dtypeis_integer_dtypeis_sequenceis_unsigned_integer_dtypepandas_dtype)
CategoricalCategoricalIndex	DataFrameDatetimeIndexIndexIntervalIndex
MultiIndex
RangeIndexSeriesbdate_range)closenetworkround_trip_localpathround_trip_pathlibround_trip_picklewrite_to_compressed)randboolrandsrands_array)assert_produces_warningmaybe_produces_warning)assert_almost_equalassert_attr_equalassert_categorical_equalassert_class_equalassert_contains_allassert_copyassert_datetime_array_equalassert_dict_equalassert_equalassert_extension_array_equalassert_frame_equalassert_index_equal!assert_indexing_slices_equivalentassert_interval_array_equalassert_is_sorted"assert_is_valid_plot_return_objectassert_metadata_equivalentassert_numpy_array_equalassert_period_array_equalassert_series_equalassert_sp_array_equalassert_timedelta_array_equalraise_assert_detail)	get_dtypeget_obj)
RNGContextdecompress_fileensure_cleanensure_clean_dir!ensure_safe_environment_variablesset_timezoneuse_numexprwith_csv_dialect)Float64Index
Int64IndexNumericIndexUInt64Index)BaseMaskedArrayExtensionArrayPandasArray)NDArrayBackedExtensionArray)extract_array)PeriodIndexTimedeltaIndex      uint8uint16uint32uint64zlist[Dtype]UNSIGNED_INT_NUMPY_DTYPESZUInt8ZUInt16ZUInt32ZUInt64UNSIGNED_INT_EA_DTYPESint8int16int32int64SIGNED_INT_NUMPY_DTYPESZInt8ZInt16ZInt32ZInt64SIGNED_INT_EA_DTYPESfloat32float64FLOAT_NUMPY_DTYPESZFloat32ZFloat64FLOAT_EA_DTYPESZ	complex64Z
complex128COMPLEX_DTYPESstrUSTRING_DTYPESzdatetime64[ns]zM8[ns]DATETIME64_DTYPESztimedelta64[ns]zm8[ns]TIMEDELTA64_DTYPESboolBOOL_DTYPESbytesBYTES_DTYPESobjectOBJECT_DTYPES<>)littlebignanNaNc                 C  s    g | ]}d D ]}|d|qqS ))YMWDhmsmsusnsZpsfsasNaT ).0clsunitr   r   </tmp/pip-unpacked-wheel-xj8nt62q/pandas/_testing/__init__.py
<listcomp>   s    r   r   r   r   r   c                 C  s$   g | ]}d D ]}t j||dqqS ))NUTCz
US/Pacificz
US/Eastern)r   tz)pa	timestamp)r   r   r   r   r   r   r      s    )r   r   r   r   c                 C  s   g | ]}t |qS r   )r   duration)r   r   r   r   r   r      s     z^$None)returnc                  C  s0   t jdd} d| kr,tD ]}td| qd S )NPANDAS_TESTING_MODEr   	deprecatealwaysosenvironget_testing_mode_warningswarningssimplefilterZtesting_modecategoryr   r   r   set_testing_mode   s    r   c                  C  s0   t jdd} d| kr,tD ]}td| qd S )Nr   r   r   ignorer   r   r   r   r   reset_testing_mode   s    r   c                   C  s   t jddd dS )zJ
    Reset the display options for printing and representing objects.
    z	^display.T)ZsilentN)pdZreset_optionr   r   r   r   reset_display_options  s    r   c                 C  s   t | t |kS )zO
    Checks if the set of unique elements of arr1 and arr2 are equivalent.
    )	frozenset)Zarr1Zarr2r   r   r   equalContents  s    r   Tc                 C  s   |t jkr2t| tr&tt| j} qt | } n|tkrFt	| } n|t
krXt
| } nn|tkrt
|  } |r| j} t j| gd dd} n:|tjks|tjkrt| } n|tkrt| } nt|| S )z
    Helper function to wrap the expected output of a test in a given box_class.

    Parameters
    ----------
    expected : np.ndarray, Index, Series
    box_cls : {Index, Series, DataFrame}

    Returns
    -------
    subclass of box_cls
       T)Zignore_index)r   array
isinstancer   rQ   npasarray_valuesr   Z_with_inferr   r   Zto_frameTconcatndarrayto_arrayNotImplementedError)expectedZbox_clsZ	transposer   r   r   box_expected  s&    



r   c                 C  s*   t | dd}|dkrt| S t| ddS )zQ
    Similar to pd.array, but does not cast numpy dtypes to nullable dtypes.
    dtypeNT)Zextract_numpy)getattrr   r   rS   )objr   r   r   r   r   ?  s    
r   c                 C  s   t jd |  S N)stringascii_uppercasekr   r   r   getColsP  s    r   
   r   c                 C  s   t td| d|dS )Nr   )ncharssizename)r   r'   r   r   r   r   r   makeStringIndexU  s    r      r   c                 K  s6   t d|dd}ttjt| | |dfd|i|S )z%make a length k index or n categoriesrW   F)r   r   replace)
categoriesr   )r'   r   r   Z
from_codesr   arange)r   nr   kwargsxr   r   r   makeCategoricalIndexY  s    r   r   c                 K  s*   t jdd| d d}tj|fd|i|S )zmake a length k IntervalIndexr   d      )numr   )r   Zlinspacer   Zfrom_breaks)r   r   r   r   r   r   r   makeIntervalIndexa  s    r   c                 C  sL   | dkrt dg|dS | dkr.t ddg|dS t ddgdg| d   |dS )Nr   Tr   r   F)r   r   r   r   r   makeBoolIndexg  s
    r   rM   c                C  s   t |}t|tjstt|rNtj| |d}t|r|d|jd d  7 }nNt	|rtj
| tj
d }|  |dtj
dd  }ntd| t|||d	S )
Nr   r      r   r   r   	   zwrong dtype )r   r   )r   r   r   r   AssertionErrorr   r   r   itemsizer   randomZrandom_samplesortrandintr   rM   )r   r   r   valuesr   r   r   makeNumericIndexo  s    r   rL   c                 C  s   t | |dd}t|S )Nra   r   r   )r   rL   r   r   Zbase_idxr   r   r   makeIntIndex  s    r   rN   c                 C  s   t | |dd}t|S )Nr[   r   )r   rN   r   r   r   r   makeUIntIndex  s    r   r   c                 K  s   t d| dfd|i|S )Nr   r   r   )r   )r   r   r   r   r   r   makeRangeIndex  s    r   rK   c                 C  s   t | |dd}t|S )Nre   r   )r   rK   r   r   r   r   makeFloatIndex  s    r   Bintr   )r   r   c                 K  s0   t ddd}t|| ||d}t|fd|i|S )N  r   )periodsfreqr   r   )r   r   r   )r   r   r   r   dtZdrr   r   r   makeDateIndex  s    r   r}   rU   c                 K  s   t jf d| ||d|S )Nz1 daystartr   r   r   )r   Ztimedelta_range)r   r   r   r   r   r   r   makeTimedeltaIndex  s    r   rT   c                 K  s&   t ddd}tjf || d|d|S )Nr   r   r   r   )r   r   Zperiod_range)r   r   r   r   r   r   r   makePeriodIndex  s    r   c                 K  sJ   | d d }t |}tjd|gfd|i|}t|| ks>t|d |  S )Nr   r   )Zfoobarnames)ranger   Zfrom_productlenr   )r   r   r   Nrngmir   r   r   makeMultiIndex  s
    r   c                  c  s    t ttttttg} | E d H  d S r   )r   r   r   r   r   r   r   )make_index_funcsr   r   r   index_subclass_makers_generator  s    	r   zIterable[Index]c                 c  s$   t ttg}|D ]}|| dV  qdS )z
    Generator which can be iterated over to get instances of all the classes
    which represent time-series.

    Parameters
    ----------
    k: length of each of the index instances
    r   N)r   r   r   )r   r   Zmake_index_funcr   r   r   all_timeseries_index_generator  s    
r   r   c              	   C  sH   t t}tjt}tjdd |j|dd}W 5 Q R X t||| dS )Nr   )invalidF)copyindexr   )r   _Nr   r   randnZerrstateastyper   )r   r   r   datar   r   r   make_rand_series  s
    r   c                 C  s
   t | dS Nr   r   r   r   r   r   makeFloatSeries  s    r  c                 C  s
   t | dS r   r  r   r   r   r   makeStringSeries  s    r  c                 C  s*   t t}t|td}t t}t||| dS )Nr   r   )r   r   r   rr   r   )r   r   r   r   r   r   makeObjectSeries  s    r  zdict[str, Series]c                     s   t t  fddttD S )Nc                   s"   i | ]}|t tjt d qS )r   )r   r   r   r   r   r   cr  r   r   
<dictcomp>  s      z!getSeriesData.<locals>.<dictcomp>)r   r   r   _Kr   r   r  r   getSeriesData  s    r
  c                 C  s*   | d krt } ttj| t| |d|dS )N)r   r   )r   r   r   r   r   r   )nperr   r   r   r   r   makeTimeSeries  s    
 
 r  c                 C  s&   | d krt } ttj| t| |dS )Nr   )r   r   r   r   r   r   )r  r   r   r   r   makePeriodSeries  s    r  c                   s    fddt tD S )Nc                   s   i | ]}|t  qS r   )r  r  r   r  r   r   r    s      z%getTimeSeriesData.<locals>.<dictcomp>r   r	  )r  r   r   r  r   getTimeSeriesData  s    r  c                   s    fddt tD S )Nc                   s   i | ]}|t  qS r   )r  r  r  r   r   r    s      z!getPeriodData.<locals>.<dictcomp>r  r  r   r  r   getPeriodData  s    r  r   c                 C  s   t | |}t|S r   )r  r   )r  r   r   r   r   r   makeTimeDataFrame  s    
r  c                  C  s   t  } t| S r   )r
  r   )r   r   r   r   makeDataFrame  s    r  c                  C  sN   t dddddg} dddd	d
gdddddgdddddgtdddd}| |fS )Nabr  deg              ?g       @g      @g      @Zfoo1Zfoo2Zfoo3Zfoo4Zfoo5z1/1/2009   )r   )Ar   Cr}   )r   r   )r   r   r   r   r   getMixedTypeDict  s    
r  c                   C  s   t t d S )Nr   )r   r  r   r   r   r   makeMixedDataFrame  s    r  c                 C  s   t | }t|S r   )r  r   )r  r   r   r   r   makePeriodFrame  s    r  #Fzbool | str | list[str] | None)r   r   c                   sd  |dkrdg| }t |r&t||ks*t|dksR|dksR|dksRt||ksRt|dksn|dkrj|dksnt|dkr fddt|D }|dkrd}t|tr|dkr|g}tttt	t
td}||}|r|| }|r|d	 |_|S |dk	rtt| d
t||k r,|dg|t|   t||ks>ttdd |D sVtg }	t|D ]x}
dd }| ||
  d }t }t|D ]&}  d|
 d| }||
 ||< qt| |dd|  }|	| qbtt|	 }| dkr|dkr dn|d	 }t|d	 |d}nF|dkrR|dkr2dn|d	 }tdd |D |d}ntj||d}|S )a  
    Create an index/multindex with given dimensions, levels, names, etc'

    nentries - number of entries in index
    nlevels - number of levels (> 1 produces multindex)
    prefix - a string prefix for labels
    names - (Optional), bool or list of strings. if True will use default
       names, if false will use no names, if a list is given, the name of
       each level in the index will be taken from the list.
    ndupe_l - (Optional), list of ints, the number of rows for which the
       label will repeated at the corresponding level, you can specify just
       the first few, the rest will use the default ndupe_l of 1.
       len(ndupe_l) <= nlevels.
    idx_type - "i"/"f"/"s"/"dt"/"p"/"td".
       If idx_type is not None, `idx_nlevels` must be 1.
       "i"/"f" creates an integer/float index,
       "s" creates a string
       "dt" create a datetime index.
       "td" create a datetime index.

        if unspecified, string labels will be generated.
    Nr   FT)ifr   ur   ptdc                   s   g | ]} t | qS r   )ri   )r   r!  prefixr   r   r   F  s     z#makeCustomIndex.<locals>.<listcomp>)r!  r"  r   r   r%  r$  r   zE is not a legal value for `idx_type`, use  'i'/'f'/'s'/'dt'/'p'/'td'.c                 s  s   | ]}|d kV  qdS r   Nr   r   r   r   r   r   	<genexpr>i  s     z"makeCustomIndex.<locals>.<genexpr>c                 S  s*   dd l }|dd| d}dd |D S )Nr   z[^\d_]_? _c                 S  s   g | ]}t |qS r   )r   )r   r   r   r   r   r   r  s     z4makeCustomIndex.<locals>.keyfunc.<locals>.<listcomp>)resubsplit)r   r-  Znumeric_tupler   r   r   keyfuncn  s    z makeCustomIndex.<locals>.keyfuncZ_lZ_g)keyr   c                 s  s   | ]}|d  V  qdS r(  r   r)  r   r   r   r*    s     )r   )r   r   r   r   r   ri   r   r   r   r   r   r   r   r   
ValueErrorreprextendallcollectionsr	   sortedelementsappendlistzipr   r   from_tuples)Znentriesnlevelsr'  r   ndupe_lidx_typeZidx_func_dictZidx_funcidxZlist_of_listsr!  r0  Z
div_factorZcntjlabelresultZtuplesr   r   r   r&  r   makeCustomIndex  sn    
(




rD  r   c                   s   |dkst |dkst |dks4|dkr0|dks4t |
dksP|
dkrL|dksPt t|d|||
d}t| |d|||d} dkrdd	   fd
dt| D }t||||	dS )a
  
    Create a DataFrame using supplied parameters.

    Parameters
    ----------
    nrows,  ncols - number of data rows/cols
    c_idx_names, idx_names  - False/True/list of strings,  yields No names ,
            default names or uses the provided names for the levels of the
            corresponding index. You can provide a single string when
            c_idx_nlevels ==1.
    c_idx_nlevels - number of levels in columns index. > 1 will yield MultiIndex
    r_idx_nlevels - number of levels in rows index. > 1 will yield MultiIndex
    data_gen_f - a function f(row,col) which return the data value
            at that position, the default generator used yields values of the form
            "RxCy" based on position.
    c_ndupe_l, r_ndupe_l - list of integers, determines the number
            of duplicates for each label at a given level of the corresponding
            index. The default `None` value produces a multiplicity of 1 across
            all levels, i.e. a unique index. Will accept a partial list of length
            N < idx_nlevels, for just the first N levels. If ndupe doesn't divide
            nrows/ncol, the last label might have lower multiplicity.
    dtype - passed to the DataFrame constructor as is, in case you wish to
            have more control in conjunction with a custom `data_gen_f`
    r_idx_type, c_idx_type -  "i"/"f"/"s"/"dt"/"td".
        If idx_type is not None, `idx_nlevels` must be 1.
        "i"/"f" creates an integer/float index,
        "s" creates a string index
        "dt" create a datetime index.
        "td" create a timedelta index.

            if unspecified, string labels will be generated.

    Examples
    --------
    # 5 row, 3 columns, default names on both, single index on both axis
    >> makeCustomDataframe(5,3)

    # make the data a random int between 1 and 100
    >> mkdf(5,3,data_gen_f=lambda r,c:randint(1,100))

    # 2-level multiindex on rows with each label duplicated
    # twice on first level, default names on both axis, single
    # index on both axis
    >> a=makeCustomDataframe(5,3,r_idx_nlevels=2,r_ndupe_l=[2])

    # DatetimeIndex on row, index with unicode labels on columns
    # no names on either axis
    >> a=makeCustomDataframe(5,3,c_idx_names=False,r_idx_names=False,
                             r_idx_type="dt",c_idx_type="u")

    # 4-level multindex on rows with names provided, 2-level multindex
    # on columns with default labels and default names.
    >> a=makeCustomDataframe(5,3,r_idx_nlevels=4,
                             r_idx_names=["FEE","FIH","FOH","FUM"],
                             c_idx_nlevels=2)

    >> a=mkdf(5,3,r_idx_nlevels=2,c_idx_nlevels=4)
    r   N)r!  r"  r   r   r$  r%  r   r  )r=  r'  r   r>  r?  Rc                 S  s   d|  d| S )NrE  r  r   )rr  r   r   r   <lambda>      z%makeCustomDataframe.<locals>.<lambda>c                   s$   g | ]  fd dt D qS )c                   s   g | ]} |qS r   r   r  )
data_gen_frF  r   r   r     s     z2makeCustomDataframe.<locals>.<listcomp>.<listcomp>)r   )r   rI  ncols)rF  r   r     s     z'makeCustomDataframe.<locals>.<listcomp>r   )r   rD  r   r   )nrowsrK  Zc_idx_namesZr_idx_namesZc_idx_nlevelsZr_idx_nlevelsrI  Z	c_ndupe_lZ	r_ndupe_lr   Z
c_idx_typeZ
r_idx_typecolumnsr   r   r   rJ  r   makeCustomDataframe  s@    H
rN  c                   s   |d krt j}nt j|}td|    d}d}t| | } fdd}|||}|jk r|d9 }|||}qdt |d  t}	||	  t}
|
	 |		 fS )Nr   r  gRQ?c                   s.   |  t|}tt|   d  S r   )Zrandr   r   uniquefloor)r   Z_extra_sizeindrK  rL  r   r   r   _gen_unique_rand  s    z-_create_missing_idx.<locals>._gen_unique_randg?r  )
r   r   ZRandomStateroundminr   rP  r   r   tolist)rL  rK  densityrandom_stateZmin_rowsZfac
extra_sizerS  rQ  rA  r!  r   rR  r   _create_missing_idx  s    

rZ  ?c                 C  s0   t  }t|j| |d\}}tj|j||f< |S )N)rW  rX  )r  rZ  shaper   rx   r   )rW  rX  Zdfr!  rA  r   r   r   makeMissingDataframe  s    r]  c                   @  s,   e Zd ZddgZedd Zedd ZdS )SubclassedSeriestestattrr   c                 C  s   dd S )Nc                  _  s
   t | |S r   r^  argsr   r   r   r   rG  '  rH  z/SubclassedSeries._constructor.<locals>.<lambda>r   selfr   r   r   _constructor   s    zSubclassedSeries._constructorc                 C  s   dd S )Nc                  _  s
   t | |S r   SubclassedDataFramera  r   r   r   rG  +  rH  z9SubclassedSeries._constructor_expanddim.<locals>.<lambda>r   rc  r   r   r   _constructor_expanddim)  s    z'SubclassedSeries._constructor_expanddimN)__name__
__module____qualname__	_metadatapropertyre  rh  r   r   r   r   r^    s
   
r^  c                   @  s*   e Zd ZdgZedd Zedd ZdS )rg  r_  c                 C  s   dd S )Nc                  _  s
   t | |S r   rf  ra  r   r   r   rG  3  rH  z2SubclassedDataFrame._constructor.<locals>.<lambda>r   rc  r   r   r   re  1  s    z SubclassedDataFrame._constructorc                 C  s   dd S )Nc                  _  s
   t | |S r   r`  ra  r   r   r   rG  7  rH  z9SubclassedDataFrame._constructor_sliced.<locals>.<lambda>r   rc  r   r   r   _constructor_sliced5  s    z'SubclassedDataFrame._constructor_slicedN)ri  rj  rk  rl  rm  re  rn  r   r   r   r   rg  .  s
   
rg  c                   @  s   e Zd Zedd ZdS )SubclassedCategoricalc                 C  s   t S r   )ro  rc  r   r   r   re  ;  s    z"SubclassedCategorical._constructorN)ri  rj  rk  rm  re  r   r   r   r   ro  :  s   ro  c                   s"   rfdd}n fdd}|S )a`  
    Create a function for calling on an array.

    Parameters
    ----------
    alternative : function
        The function to be called on the array with no NaNs.
        Only used when 'skipna_alternative' is None.
    skipna_alternative : function
        The function to be called on the original array

    Returns
    -------
    function
    c                   s
    | j S r   )r   r   )skipna_alternativer   r   skipna_wrapperR  s    z,_make_skipna_wrapper.<locals>.skipna_wrapperc                   s"   |   }t|dkrtjS  |S )Nr   )Zdropnar   r   rx   )r   Znona)alternativer   r   rr  W  s    r   )rs  rq  rr  r   )rs  rq  r   _make_skipna_wrapper@  s    rt  z	list[str])	rows_listr   c                 C  s   t j}|| | S )aW  
    Convert list of CSV rows to single CSV-formatted string for current OS.

    This method is used for creating expected value of to_csv() method.

    Parameters
    ----------
    rows_list : List[str]
        Each element represents the row of csv.

    Returns
    -------
    str
        Expected output of to_csv() in current OS.
    )r   linesepjoin)ru  sepr   r   r   convert_rows_list_to_csv_str`  s    ry  ztype[Exception]r   )expected_exceptionr   c                 C  s   ddl }|j| ddS )a$  
    Helper function to mark pytest.raises that have an external error message.

    Parameters
    ----------
    expected_exception : Exception
        Expected error to raise.

    Returns
    -------
    Callable
        Regular `pytest.raises` function with `match` equal to `None`.
    r   N)match)pytestZraises)rz  r|  r   r   r   external_error_raisedt  s    r}  c                   s@   g }|D ]2\ |  f | fddtD 7 }q|S )a  
    Combine frame, functions from com._cython_table
    keys and expected result.

    Parameters
    ----------
    ndframe : DataFrame or Series
    func_names_and_expected : Sequence of two items
        The first item is a name of a NDFrame method ('sum', 'prod') etc.
        The second item is the expected return value.

    Returns
    -------
    list
        List of three items (DataFrame, function, expected result)
    c                   s"   g | ]\}}|kr| fqS r   r   )r   funcr   r   	func_namendframer   r   r     s   z+get_cython_table_params.<locals>.<listcomp>)r9  cython_table)r  Zfunc_names_and_expectedresultsr   r  r   get_cython_table_params  s    
r  r   )op_namer   c                   sP   |  d}ztt|}W n2 tk
rJ   tt|dd   fdd}Y nX |S )z
    The operator function for a given op name.

    Parameters
    ----------
    op_name : str
        The op name, in form of "add" or "__add__".

    Returns
    -------
    function
        A function performing the operation.
    r,  r   Nc                   s
    || S r   r   )r   yZropr   r   rG    rH  z"get_op_from_name.<locals>.<lambda>)stripr   operatorAttributeError)r  Zshort_opnameopr   r  r   get_op_from_name  s    
r  c                 C  s   | S r   r   rp  r   r   r   getitem  s    r  c                 C  s   | S r   r   rp  r   r   r   setitem  s    r  c                 C  s   | j S r   )locrp  r   r   r   r    s    r  c                 C  s   | j S r   )ilocrp  r   r   r   r    s    r  c                 C  s   | j S r   )atrp  r   r   r   r    s    r  c                 C  s   | j S r   )iatrp  r   r   r   r    s    r  c                 C  s  t | tjr$t |tjr$t| |S t | tjr:t|| S t | trHdS t | tr^t| j|S t | ttfrxt| j	|S t | t
rt| j|S t | tjjjrt| j|S t | tjjjrt| j|pt| j|S t | tr:| jdkr:t |tr:|jdkr:| j}|j}|d d }|d d }||kS t | trtt |trtt| j|jprt| j|jS t | trt| jjdkr| jjd }t||S tt| t|dS )z-
    Pandas-compat for np.shares_memory.
    Fzstring[pyarrow]r   r   N) r   r   r   shares_memoryr   r   _codesr   r   r   rR   Z_ndarrayr   coreZarraysZSparseArrayZ	sp_valuesZIntervalArray_leftZ_rightrP   r   _datachunkbuffersrO   Z_maskr   r   Z_mgrr   type)leftrightZleft_pa_dataZright_pa_dataZ	left_buf1Z
right_buf1Zarrr   r   r   r    s@    



 
r  ALL_INT_EA_DTYPESALL_INT_NUMPY_DTYPESALL_NUMPY_DTYPESALL_REAL_NUMPY_DTYPESr*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r(   r=   r>   r?   r   r   rD   EMPTY_STRING_PATTERNENDIANrE   rF   rG   rA   r   rB   r)   NARROW_NP_DTYPESr    NP_NAT_OBJECTSNULL_OBJECTSr@   r%   r&   rC   r!   r"   r#   r   rH   rI   rJ   r$   )T)r   N)r   r   N)r   N)r   N)r   N)r   N)r   N)r   N)r   N)r   r   N)r   r}   N)r   N)r   N)r   )N)N)N)Nr   N)NN)Nr   )N)Nr   )N)r   FNN)
TTr   r   NNNNNN)N)r[  N)N)
__future__r   r6  r   decimalr   r  r   r-  r   sysr   typingr   r   r   r	   r
   r   Znumpyr   Zpandas._config.localizationr   r   r   Zpandas._typingr   Zpandas.compatr   Zpandas.core.dtypes.commonr   r   r   r   r   Zpandasr   r   r   r   r   r   r   r   r   r   r   Zpandas._testing._ior   r    r!   r"   r#   r$   Zpandas._testing._randomr%   r&   r'   Zpandas._testing._warningsr(   r)   Zpandas._testing.assertersr*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   Zpandas._testing.compatrA   rB   Zpandas._testing.contextsrC   rD   rE   rF   rG   rH   rI   rJ   Zpandas.core.apirK   rL   rM   rN   Zpandas.core.arraysrO   rP   rQ   Zpandas.core.arrays._mixinsrR   Zpandas.core.constructionrS   rT   rU   r   r	  r\   __annotations__r]   r   rb   rc   r  r  floatrf   rg   complexrh   ri   rk   rl   rm   rn   ro   rp   rq   rr   rs   r  r  Zfloat16rd   r^   r_   r`   rX   rY   rZ   r  r  rx   r   ZNAr  Z
datetime64Ztimedelta64r  Zpyarrowr   r[   ZUNSIGNED_INT_PYARROW_DTYPESra   ZSIGNED_INT_PYARROW_DTYPESZALL_INT_PYARROW_DTYPESre   ZFLOAT_PYARROW_DTYPESutf8ZSTRING_PYARROW_DTYPESZtime32Ztime64ZTIME_PYARROW_DTYPESZdate32Zdate64ZDATE_PYARROW_DTYPESZDATETIME_PYARROW_DTYPESZTIMEDELTA_PYARROW_DTYPESZbool_ZBOOL_PYARROW_DTYPESZALL_PYARROW_DTYPEScompiler  DeprecationWarningResourceWarningr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r
  r  r  r  r  r  r  r  r  r  rD  rN  rZ  r]  r^  rg  ro  rt  ry  r}  r  commonZ_cython_tableitemsr  r  r  r  r  r  r  r  r  r  __all__r   r   r   r   <module>   sb   0 d(



)   u         k 2