/ lib / pandas / _testing / __init__.pyc
__init__.pyc
  1  o

  2  c��c5��@sXUddlmZddlZddlmZddlmZddlZddlZddlZddl	Z	ddl
  3  mZddlm
Z
mZmZmZmZddlZddlZddlmZmZmZddlmZdd	lmZdd
  4  lmZmZm Z m!Z!m"Z"ddl#Z$ddl#m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5dd
l6m7Z7m8Z8m9Z9ddl:m;Z;m<Z<ddl=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTddlUmVZVmWZWddlXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`ddlambZbmcZcmdZdmeZeddlfmgZgmhZhmiZiddljmkZkddllmmZme
�r ddl#mnZnmoZodZpdZqgd�Zrdesd<gd�Ztdesd<euddd d!gZvdesd"<gd#�Zwdesd$<erevZxetewZyezd%d&gZ{desd'<d(d)gZ|desd*<e}d+d,gZ~desd-<ed.d/gZ�desd0<d1d2gZ�desd3<d4d5gZ�desd6<e�d7gZ�desd8<e�d9gZ�desd:<e�d;gZ�desd<<e{exZ�e�e~e�e�e�e�e�e�Z�ej�ej�ej�ej�ej�ej�ej�ej�gZ�d=d>d?�eZ�dej�e$j�ezd@�e$j�edA�gZ�dBdC�ej�ej�fD�Z�e�sSddl�Z�e����e����e����e����gZ�e����e����e����e����gZ�e�e�Z�e����e����gZ�e��	�e����gZ�e���dD�e���dE�e���dF�e���dG�gZ�e����e����gZ�dHdC�dID�Z�dJdC�dID�Z�e����gZ�e�e�e�e�e�e�e�Z�e��dK�Z�e�e�fZ�d�dNdO�Z�d�dPdQ�Z�e��d�dRdS�Z�d�dTdU�Z�d�dWdX�Z�dYdZ�Z�d�d[d\�Z�d�d�d_d`�Z�d�d�dcdd�Z�d�d�dfdg�Z�d�d�dhdi�Z�d�d�dkdl�Z�d�d�dndo�Z�d�d�dqdr�Z�d�d�dtdu�Z�d�d�dwdx�Z�d�d�d}d~�Z�d�d�d�d��Z�d�d�d�d��Z�d�d�d��Z�d�d��Z�d�d�d�d��Z�dej�fd�d�d��Z�d�d�d�d��Z�d�d�d�d��Z�d�d�d�d��Z�d�d�d��Z�d�d�d�d��Z�d�d�d�d��Z�d�d�d�d��Z�d�d�d�d��Z�d�d�d�d��Z�d�d�d��Z�d�d��Z�d�d�d��Z�d�d�d�d��Z�	�	�		d�d�d�d��Z�	V	V	�	�						d�d�d�d��Z�d�d�d��Z�d�d�d�d��Z�Gd�d��d�e-�Z�Gd�d��d�e'�Z�Gd�d��d�e%�Z�d�d�d��Z�dd�dńZ�dd�dʄZ�e$j�j�j��Z�d�d̄Z�dd�dЄZ�d�d҄Z�d�dԄZ�d�dքZ�d�d؄Z�d�dڄZ�d�d܄Z�d�d�dބZ�gdߢZ�dS(�)�annotationsN)�datetime)�Decimal)�	byteorder)�
TYPE_CHECKING�Callable�ContextManager�Counter�Iterable)�can_set_locale�get_locales�
  5  set_locale)�Dtype)�pa_version_under1p01)�is_float_dtype�is_integer_dtype�is_sequence�is_unsigned_integer_dtype�pandas_dtype)
  6  �Categorical�CategoricalIndex�	DataFrame�
DatetimeIndex�Index�
IntervalIndex�
  7  MultiIndex�
  8  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)�
  9  RNGContext�decompress_file�ensure_clean�ensure_clean_dir�!ensure_safe_environment_variables�set_timezone�use_numexpr�with_csv_dialect)�Float64Index�
 10  Int64Index�NumericIndex�UInt64Index)�BaseMaskedArray�ExtensionArray�PandasArray)�NDArrayBackedExtensionArray)�
extract_array)�PeriodIndex�TimedeltaIndex��)�uint8�uint16�uint32�uint64zlist[Dtype]�UNSIGNED_INT_NUMPY_DTYPES)�UInt8�UInt16�UInt32�UInt64�UNSIGNED_INT_EA_DTYPES�int8�int16�int32�int64�SIGNED_INT_NUMPY_DTYPES)�Int8�Int16�Int32�Int64�SIGNED_INT_EA_DTYPES�float32�float64�FLOAT_NUMPY_DTYPES�Float32�Float64�FLOAT_EA_DTYPES�	complex64�
 11  complex128�COMPLEX_DTYPES�str�U�
STRING_DTYPESzdatetime64[ns]zM8[ns]�DATETIME64_DTYPESztimedelta64[ns]zm8[ns]�TIMEDELTA64_DTYPES�bool�BOOL_DTYPES�bytes�BYTES_DTYPES�object�
OBJECT_DTYPES�<�>)�little�big�nan�NaNcCs g|]}dD]}|d|��qqS))
�Y�M�W�D�h�m�s�ms�us�ns�ps�fs�as�NaT�)�.0�cls�unitr�r���C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\_testing\__init__.py�
 12  <listcomp>�s���r�r�r�r�r�cCs$g|]}dD]	}tj||d��qqS))N�UTCz
 13  US/Pacificz
 14  US/Eastern)r��tz)�pa�	timestamp)r�r�r�r�r�r�r��s���)r�r�r�r�cCsg|]}t�|��qSr�)r��duration)r�r�r�r�r�r���z^$�return�NonecC�4tj�dd�}d|vrtD]
 15  }t�d|�q
dSdS)N�PANDAS_TESTING_MODEr��	deprecate�always��os�environ�get�_testing_mode_warnings�warnings�simplefilter�Ztesting_mode�categoryr�r�r��set_testing_mode���r�cCr�)Nr�r�r��ignorer�r�r�r�r��reset_testing_mode�r�r�cCstjddd�dS)zJ
 16      Reset the display options for printing and representing objects.
 17      z	^display.T)�silentN)�pd�reset_optionr�r�r�r��reset_display_optionssr�cCst|�t|�kS)zO
 18      Checks if the set of unique elements of arr1 and arr2 are equivalent.
 19      )�	frozenset)�arr1�arr2r�r�r��
equalContentssr�TcCs�|tjurt|t�rtt�|j��}|St�|�}|S|tur&t�	|�}|S|t
 20  ur0t
 21  |�}|S|turKt
 22  |���}|rI|j
}tj|gddd�}|S|tjusU|tjur\t�|�}|S|turft|�}|St|��)z�
 23      Helper function to wrap the expected output of a test in a given box_class.
 24  
 25      Parameters
 26      ----------
 27      expected : np.ndarray, Index, Series
 28      box_cls : {Index, Series, DataFrame}
 29  
 30      Returns
 31      -------
 32      subclass of box_cls
 33      �T)�ignore_index)r��array�
 34  isinstancerrQ�np�asarray�_valuesr�_with_inferrr�to_frame�T�concat�ndarray�to_array�NotImplementedError)�expectedZbox_cls�	transposer�r�r��box_expecteds2
 35  
 36  
 37  ��
 38  ���
 39  ��r�cCs*t|dd�}|durt�|�St|dd�S)zQ
 40      Similar to pd.array, but does not cast numpy dtypes to nullable dtypes.
 41      �dtypeNT)�
extract_numpy)�getattrr�r�rS)�objr�r�r�r�r�?s
 42  r�cCstjd|�S�N)�string�ascii_uppercase��kr�r�r��getColsP�r��
 43  rcCsttd|d�|d�S)Nr�)�nchars�size��name)rr'�r�r�r�r�r��makeStringIndexUsr��rcKs6td|dd�}ttjt�|�||d�fd|i|��S)z%make a length k index or n categoriesrWF)r�r��replace)�
 44  categoriesr�)r'rr�
 45  from_codesr��arange)r��nr��kwargs�xr�r�r��makeCategoricalIndexYs���r�rcKs*tjdd|dd�}tj|fd|i|��S)zmake a length k IntervalIndexr�d�)�numr�)r��linspacer�from_breaks)r�r�r�r�r�r�r��makeIntervalIndexasr�cCsL|dkrtdg|d�S|dkrtddg|d�Stddgdg|d|d�S)Nr�Tr�r�F)rr�r�r�r��
makeBoolIndexgs
 46  r�rMcCs�t|�}t|tj�sJ�t|�r'tj||d�}t|�r&|d|jdd7}n't|�rGtj	�
 47  |�tj	�
 48  d�}|��|dtj	�dd�}nt
d|����t|||d	�S)
 49  N�r�r��r�r�r�	zwrong dtype )r�r�)rr�r�r�rr�r�itemsizer�random�
random_sample�sort�randintr�rM)r�r�r��valuesr�r�r��makeNumericIndexos�r�rLcC�t||dd�}t|�S)Nre�r�r�)r�rL�r�r�Zbase_idxr�r�r��makeIntIndex��r�rNcCr�)Nr[r�)r�rNr�r�r�r��
makeUIntIndex�r�r�rcKstd|dfd|i|��S)Nrr�r�)r)r�r�r�r�r�r��makeRangeIndex��r�rKcCr�)Nrmr�)r�rKr�r�r�r��makeFloatIndex�r�r�Br��intrcKs0tddd�}t||||d�}t|fd|i|��S)N��r�)�periods�freqr�r�)rrr)r�rr�r��dt�drr�r�r��
makeDateIndex�srr�rUcKstjdd|||d�|��S)Nz1 day��startrrr�r�)r��timedelta_range)r�rr�r�r�r�r��makeTimedeltaIndex�srrTcKs&tddd�}tjd||d|d�|��S)Nrr�rr	r�)rr��period_range)r�r�r�rr�r�r��makePeriodIndex�srcKsJ|dd}t|�}tjd|gfd|i|��}t|�|ksJ�|d|�S)Nr�r�)�foo�bar�names)�ranger�from_product�len)r�rr��N�rng�mir�r�r��makeMultiIndex�s
 50  rccs"�tttttttg}|EdHdSr�)rrrr�r�r�r)�make_index_funcsr�r�r��index_subclass_makers_generator�s��	r�Iterable[Index]ccs&�tttg}|D]}||d�VqdS)z�
 51      Generator which can be iterated over to get instances of all the classes
 52      which represent time-series.
 53  
 54      Parameters
 55      ----------
 56      k: length of each of the index instances
 57      r�N)rrr)r�rZmake_index_funcr�r�r��all_timeseries_index_generator�s�
 58  ��rrcCs\tt�}tj�t�}tjdd��|j|dd�}Wd�n1s"wYt|||d�S)Nr�)�invalidF)�copy��indexr�)r��_Nr�r��randn�errstate�astyper)r�r�r �datar�r�r��make_rand_series�s�r&cC�
 59  t|d�S�Nr��r&r�r�r�r��makeFloatSeries��
 60  r*cCr'r(r)r�r�r�r��makeStringSeries�r+r,cCs*tt�}t|td�}tt�}t|||d�S)Nr�r)r�r!rr~r)r�r%r r�r�r��makeObjectSeries�sr-�dict[str, Series]cstt���fdd�tt�D�S)Ncs"i|]
}|ttj�t��d��qS)�r )rr�r�r"r!�r��cr/r�r��
 61  <dictcomp>�s"z!getSeriesData.<locals>.<dictcomp>)r�r!r��_Kr�r�r/r��
getSeriesData�sr4cCs*|durt}ttj�|�t||d�|d�S)N)rr)r!rr�r�r"r)�nperrr�r�r�r��makeTimeSeries�s
 62  �r6cCs&|durt}ttj�|�t|�|d�S)Nr)r!rr�r�r"r)r5r�r�r�r��makePeriodSeries�sr7cs��fdd�tt�D�S)Ncsi|]}|t����qSr�)r6r0�rr5r�r�r2��z%getTimeSeriesData.<locals>.<dictcomp>�r�r3)r5rr�r8r��getTimeSeriesData�r�r;cs�fdd�tt�D�S)Ncsi|]}|t���qSr�)r7r0�r5r�r�r2�r�z!getPeriodData.<locals>.<dictcomp>r:r<r�r<r��
getPeriodData�sr=rcCst||�}t|�Sr�)r;r)r5rr%r�r�r��makeTimeDataFrame�s
 63  r>cCst�}t|�Sr�)r4r)r%r�r�r��
makeDataFramesr?cCs6tgd��}gd�gd�gd�tddd�d�}||fS)	N)�a�br1�d�e)���?g@g@g@)rDrErDrErD)�foo1�foo2Zfoo3Zfoo4Zfoo5z1/1/2009�)r)�Ar�Cr�)rr)r r%r�r�r��getMixedTypeDicts
 64  �rKcCstt�d�S)Nr�)rrKr�r�r�r��makeMixedDataFramer�rLcCst|�}t|�Sr�)r=r)r5r%r�r�r��makePeriodFramesrM�#Fr�bool | str | list[str] | NonecsZ|dur	dg|}t|�rt|�|ksJ�|dus)|dus)|dus)t|�|us)J�|dus7|dvr5|dks7J�|durF�fdd�t|�D�}|durLd}t|t�rX|dkrX|g}ttttt	t
 65  d�}|�|�}|ru||�}|rs|d	|_|S|dur�t
t|��d
 66  ���t|�|kr�|�dg|t|��t|�|ks�J�tdd�|D��s�J�g}	t|�D]:}
 67  d
d�}|||
 68  d}t��}
t|�D]}��d|
 69  �d|��}||
 70  |
|<q�t|
��|d�d|�}|	�|�q�tt|	��}|dk�r|dur�dn|d	}t|d	|d�}|S|dk�r$|du�rdn|d	}tdd�|D�|d�}|Stj||d�}|S)a�
 71      Create an index/multindex with given dimensions, levels, names, etc'
 72  
 73      nentries - number of entries in index
 74      nlevels - number of levels (> 1 produces multindex)
 75      prefix - a string prefix for labels
 76      names - (Optional), bool or list of strings. if True will use default
 77         names, if false will use no names, if a list is given, the name of
 78         each level in the index will be taken from the list.
 79      ndupe_l - (Optional), list of ints, the number of rows for which the
 80         label will repeated at the corresponding level, you can specify just
 81         the first few, the rest will use the default ndupe_l of 1.
 82         len(ndupe_l) <= nlevels.
 83      idx_type - "i"/"f"/"s"/"dt"/"p"/"td".
 84         If idx_type is not None, `idx_nlevels` must be 1.
 85         "i"/"f" creates an integer/float index,
 86         "s" creates a string
 87         "dt" create a datetime index.
 88         "td" create a datetime index.
 89  
 90          if unspecified, string labels will be generated.
 91      Nr�FT)�i�fr��ur�p�tdcsg|]}�t|��qSr�)ru)r�rP��prefixr�r�r�Fr9z#makeCustomIndex.<locals>.<listcomp>)rPrQr�rrTrSrzE is not a legal value for `idx_type`, use  'i'/'f'/'s'/'dt'/'p'/'td'.css�|]}|dkVqdS�rNr��r�r�r�r�r��	<genexpr>i��z"makeCustomIndex.<locals>.<genexpr>cSs*ddl}|�dd|��d�}dd�|D�S)Nrz[^\d_]_?��_cSsg|]}t|��qSr�)r)r�r�r�r�r�r�rsz4makeCustomIndex.<locals>.keyfunc.<locals>.<listcomp>)�re�sub�split)r�r]Z
numeric_tupler�r�r��keyfuncnsz makeCustomIndex.<locals>.keyfunc�_l�_g)�keyr�css�|]}|dVqdSrWr�rXr�r�r�rY�rZ)r)rrrr�rur�rr�rrrr�r��
 92  ValueError�repr�extend�all�collectionsr	�sorted�elements�append�list�ziprr�from_tuples)Znentries�nlevelsrVr�ndupe_l�idx_typeZ
idx_func_dictZidx_func�idxZ
list_of_listsrPr`Z
 93  div_factor�cnt�j�label�result�tuplesr�r r�rUr��makeCustomIndexsl
 94  (�
 95  
 96  �
 97  
 98  ��rxr�cs�|dksJ�|dksJ�|dus|dvr|dksJ�|
 99  dus(|
100  dvr&|dks(J�t�|d|||
101  d�}t||d|||d�}
�durDdd	����fd
102  d�t|�D�}t||
||	d�S)
a�
103  
104      Create a DataFrame using supplied parameters.
105  
106      Parameters
107      ----------
108      nrows,  ncols - number of data rows/cols
109      c_idx_names, idx_names  - False/True/list of strings,  yields No names ,
110              default names or uses the provided names for the levels of the
111              corresponding index. You can provide a single string when
112              c_idx_nlevels ==1.
113      c_idx_nlevels - number of levels in columns index. > 1 will yield MultiIndex
114      r_idx_nlevels - number of levels in rows index. > 1 will yield MultiIndex
115      data_gen_f - a function f(row,col) which return the data value
116              at that position, the default generator used yields values of the form
117              "RxCy" based on position.
118      c_ndupe_l, r_ndupe_l - list of integers, determines the number
119              of duplicates for each label at a given level of the corresponding
120              index. The default `None` value produces a multiplicity of 1 across
121              all levels, i.e. a unique index. Will accept a partial list of length
122              N < idx_nlevels, for just the first N levels. If ndupe doesn't divide
123              nrows/ncol, the last label might have lower multiplicity.
124      dtype - passed to the DataFrame constructor as is, in case you wish to
125              have more control in conjunction with a custom `data_gen_f`
126      r_idx_type, c_idx_type -  "i"/"f"/"s"/"dt"/"td".
127          If idx_type is not None, `idx_nlevels` must be 1.
128          "i"/"f" creates an integer/float index,
129          "s" creates a string index
130          "dt" create a datetime index.
131          "td" create a timedelta index.
132  
133              if unspecified, string labels will be generated.
134  
135      Examples
136      --------
137      # 5 row, 3 columns, default names on both, single index on both axis
138      >> makeCustomDataframe(5,3)
139  
140      # make the data a random int between 1 and 100
141      >> mkdf(5,3,data_gen_f=lambda r,c:randint(1,100))
142  
143      # 2-level multiindex on rows with each label duplicated
144      # twice on first level, default names on both axis, single
145      # index on both axis
146      >> a=makeCustomDataframe(5,3,r_idx_nlevels=2,r_ndupe_l=[2])
147  
148      # DatetimeIndex on row, index with unicode labels on columns
149      # no names on either axis
150      >> a=makeCustomDataframe(5,3,c_idx_names=False,r_idx_names=False,
151                               r_idx_type="dt",c_idx_type="u")
152  
153      # 4-level multindex on rows with names provided, 2-level multindex
154      # on columns with default labels and default names.
155      >> a=makeCustomDataframe(5,3,r_idx_nlevels=4,
156                               r_idx_names=["FEE","FIH","FOH","FUM"],
157                               c_idx_nlevels=2)
158  
159      >> a=mkdf(5,3,r_idx_nlevels=2,c_idx_nlevels=4)
160      rN)rPrQr�rrSrTr�rJ)rorVrrprq�RcSsd|�d|��S)NryrJr�)�rr1r�r�r��<lambda>�sz%makeCustomDataframe.<locals>.<lambda>cs$g|]���fdd�t��D��qS)csg|]}��|��qSr�r�r0)�
161  data_gen_frzr�r�r��r�z2makeCustomDataframe.<locals>.<listcomp>.<listcomp>)r)r��r|�ncols)rzr�r��s$z'makeCustomDataframe.<locals>.<listcomp>r�)rxrr)�nrowsr~Zc_idx_namesZr_idx_namesZ
c_idx_nlevelsZ
r_idx_nlevelsr|Z	c_ndupe_lZ	r_ndupe_lr�Z
162  c_idx_typeZ
163  r_idx_type�columnsr r%r�r}r��makeCustomDataframe�s4H��
164  r�cs�|durtj}ntj�|�}td|����d}d}t�||��}���fdd�}|||�}|j�krE|d9}|||�}|j�ks7t�|d���t�}	||	��t�}
165  |
166  �	�|	�	�fS)Nr�rHgR���Q�?cs.|�t|��}t�t�|����d��Sr�)�randrr��unique�floor)rZ_extra_size�ind�r~rr�r�r��_gen_unique_rands z-_create_missing_idx.<locals>._gen_unique_randg�������?rE)
167  r�r��RandomState�round�minr�r�r$r�tolist)rr~�density�random_state�min_rows�fac�
168  extra_sizer�r�rtrPr�r�r��_create_missing_idx�s 
169  
170  
171  
172  �r���������?cCs0t�}t|j||d��\}}tj|j||f<|S)N)r�r�)r?r��shaper�r�r�)r�r��dfrPrtr�r�r��makeMissingDataframesr�c@s,eZdZddgZedd��Zedd��ZdS)�SubclassedSeries�testattrr�cC�dd�S)Nc_�t|i|��Sr��r���argsr�r�r�r�r{'�z/SubclassedSeries._constructor.<locals>.<lambda>r���selfr�r�r��_constructor szSubclassedSeries._constructorcCr�)Nc_r�r���SubclassedDataFramer�r�r�r�r{+r�z9SubclassedSeries._constructor_expanddim.<locals>.<lambda>r�r�r�r�r��_constructor_expanddim)�z'SubclassedSeries._constructor_expanddimN)�__name__�
173  __module__�__qualname__�	_metadata�propertyr�r�r�r�r�r�r�s
174  r�c@s*eZdZdgZedd��Zedd��ZdS)r�r�cCr�)Nc_r�r�r�r�r�r�r�r{3r�z2SubclassedDataFrame._constructor.<locals>.<lambda>r�r�r�r�r�r�1r�z SubclassedDataFrame._constructorcCr�)Nc_r�r�r�r�r�r�r�r{7r�z9SubclassedDataFrame._constructor_sliced.<locals>.<lambda>r�r�r�r�r��_constructor_sliced5r�z'SubclassedDataFrame._constructor_slicedN)r�r�r�r�r�r�r�r�r�r�r�r�.s
175  r�c@seZdZedd��ZdS)�SubclassedCategoricalcCstSr�)r�r�r�r�r�r�;sz"SubclassedCategorical._constructorN)r�r�r�r�r�r�r�r�r�r�:sr�cs$�r
176  �fdd�}|S�fdd�}|S)a`
177      Create a function for calling on an array.
178  
179      Parameters
180      ----------
181      alternative : function
182          The function to be called on the array with no NaNs.
183          Only used when 'skipna_alternative' is None.
184      skipna_alternative : function
185          The function to be called on the original array
186  
187      Returns
188      -------
189      function
190      cs
191  �|j�Sr�)r��r�)�skipna_alternativer�r��skipna_wrapperRr+z,_make_skipna_wrapper.<locals>.skipna_wrappercs"|��}t|�dkr
tjS�|�S)Nr)�dropnarr�r�)r�Znona)�alternativer�r�r�Wsr�)r�r�r�r�)r�r�r��_make_skipna_wrapper@s
192  �r��	rows_list�	list[str]cCstj}|�|�|S)aW
193      Convert list of CSV rows to single CSV-formatted string for current OS.
194  
195      This method is used for creating expected value of to_csv() method.
196  
197      Parameters
198      ----------
199      rows_list : List[str]
200          Each element represents the row of csv.
201  
202      Returns
203      -------
204      str
205          Expected output of to_csv() in current OS.
206      )r��linesep�join)r��sepr�r�r��convert_rows_list_to_csv_str`sr��expected_exception�type[Exception]rcCsddl}|j|dd�S)a$
207      Helper function to mark pytest.raises that have an external error message.
208  
209      Parameters
210      ----------
211      expected_exception : Exception
212          Expected error to raise.
213  
214      Returns
215      -------
216      Callable
217          Regular `pytest.raises` function with `match` equal to `None`.
218      rN)�match)�pytest�raises)r�r�r�r�r��external_error_raisedtsr�cs@g}|D]\��|����f�|���fdd�tD�7}q|S)a�
219      Combine frame, functions from com._cython_table
220      keys and expected result.
221  
222      Parameters
223      ----------
224      ndframe : DataFrame or Series
225      func_names_and_expected : Sequence of two items
226          The first item is a name of a NDFrame method ('sum', 'prod') etc.
227          The second item is the expected return value.
228  
229      Returns
230      -------
231      list
232          List of three items (DataFrame, function, expected result)
233      cs"g|]
\}}|�kr�|�f�qSr�r�)r��funcr��r��	func_name�ndframer�r�r��s
234  �z+get_cython_table_params.<locals>.<listcomp>)rk�cython_table)r�Zfunc_names_and_expected�resultsr�r�r��get_cython_table_params�s
235  �r��op_namercsN|�d�}ztt|�}W|Sty&tt|dd����fdd�}Y|Sw)z�
236      The operator function for a given op name.
237  
238      Parameters
239      ----------
240      op_name : str
241          The op name, in form of "add" or "__add__".
242  
243      Returns
244      -------
245      function
246          A function performing the operation.
247      r\r�Ncs
248  �||�Sr�r�)r��y��ropr�r�r{�s
249  z"get_op_from_name.<locals>.<lambda>)�stripr��operator�AttributeError)r�Zshort_opname�opr�r�r��get_op_from_name�s
250  ��r�cC�|Sr�r�r�r�r�r��getitem��r�cCr�r�r�r�r�r�r��setitem�r�r�cC�|jSr�)�locr�r�r�r�r���r�cCr�r�)�ilocr�r�r�r�r��r�r�cCr�r�)�atr�r�r�r�r��r�r�cCr�r�)�iatr�r�r�r�r��r�r�cCs�t|tj�rt|tj�rt�||�St|tj�rt||�St|t�r$dSt|t�r/t|j|�St|ttf�r<t|j	|�St|t
251  �rGt|j|�St|tj
jj�rUt|j|�St|tj
jj�rit|j|�pht|j|�St|t�r�|jdkr�t|t�r�|jdkr�|j}|j}|�d���d}|�d���d}||kSt|t�r�t|t�r�t�|j|j�p�t�|j|j�St|t�r�t|jj�dkr�|jjd}t||�Stt|�t|���)z-
252      Pandas-compat for np.shares_memory.
253      Fzstring[pyarrow]rr�) r�r�r��
shares_memoryrr�_codesrrr�rR�_ndarrayr��core�arrays�SparseArray�	sp_values�
IntervalArray�_left�_rightrPr��_data�chunk�buffersrO�_maskrr�_mgrr��type)�left�rightZleft_pa_dataZ
right_pa_dataZ	left_buf1Z
254  right_buf1�arrr�r�r�r��s>
255  
256  
257  
258  �
259  r�)y�ALL_INT_EA_DTYPES�ALL_INT_NUMPY_DTYPES�ALL_NUMPY_DTYPES�ALL_REAL_NUMPY_DTYPESrr*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r(r=r>r?r�r{r�r}rrrtr�rxrD�EMPTY_STRING_PATTERN�ENDIANrErFrGr�r�rqrnr�r�rAr�rrKrBr�r=r4r;r�r�rr�r�r�r�rxr?rrr*r�r�r�rLrr�r-rMrr7r&r�r�r,r>rr6r�r)�NARROW_NP_DTYPESr �NP_NAT_OBJECTS�NULL_OBJECTSrr@r%r&r�r�rCr!r"r#r�r
r�rHr�rkrfrwr�r�r�ryr�rar\rIrJr$)r�r�)r�rz)T)r�ru)r�N)r�r)r�r�N)r�r)r�r)r�rM)r�rL)r�rN)r�r)r�rK)r�rN)r�rr�r)r�r�N)r�rr�rU)r�rr�rT)r�)r�rr�r)r�rr�)r�r.)NrN)NN)Nr)r�r)rNFNN)rrOr�r)
260  TTr�r�NNNNNN)r�N)r�r�r�ru)r�r�r�r)r�rur�r)��
261  __future__rrhr�decimalrr�r�r]r��sysr�typingrrrr	r
262  r��numpyr��pandas._config.localizationrrr
�pandas._typingr�
pandas.compatr�pandas.core.dtypes.commonrrrrr�pandasr�rrrrrrrrrr�pandas._testing._iorr r!r"r#r$�pandas._testing._randomr%r&r'�pandas._testing._warningsr(r)�pandas._testing.assertersr*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@�pandas._testing.compatrArB�pandas._testing.contextsrCrDrErFrGrHrIrJ�pandas.core.apirKrLrMrN�pandas.core.arraysrOrPrQ�pandas.core.arrays._mixinsrR�pandas.core.constructionrSrTrUr!r3r\�__annotations__rarrfrkr�r��floatrnrq�complexrtrurwrxryrzr{r|r}r~rr�r��float16rlrbrcrdrXrYrZr�r�r�r��NAr��
263  datetime64�timedelta64r��pyarrowr�r[�UNSIGNED_INT_PYARROW_DTYPESre�SIGNED_INT_PYARROW_DTYPES�ALL_INT_PYARROW_DTYPESrm�FLOAT_PYARROW_DTYPES�utf8�STRING_PYARROW_DTYPESZtime32Ztime64�TIME_PYARROW_DTYPESZdate32Zdate64�DATE_PYARROW_DTYPES�DATETIME_PYARROW_DTYPES�TIMEDELTA_PYARROW_DTYPES�bool_�BOOL_PYARROW_DTYPES�ALL_PYARROW_DTYPES�compiler��DeprecationWarning�ResourceWarningr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrr&r*r,r-r4r6r7r;r=r>r?rKrLrMrxr�r�r�r�r�r�r�r�r�r��common�
_cython_table�itemsr�r�r�r�r�r�r�r�r�r��__all__r�r�r�r��<module>sp0 d(
264  ���������
265  ���
266  �������
267  
268  
269  
270  
271  
272  )
273  
274  

275  
276  
277  
�u�
278  k
279   
280  1