HOME


sh-3ll 1.0
DIR:/usr/local/lib64/python3.6/site-packages/pandas/tests/__pycache__/
Upload File :
Current File : //usr/local/lib64/python3.6/site-packages/pandas/tests/__pycache__/test_strings.cpython-36.pyc
3

���h�
�,@s�ddlmZmZddlZddlZddlmZddlZddlm	Z	ddl
Zddl
mZm
Z
mZmZmZmZmZddljZddljjZdd�Zdfd	d
ifdeed��fd
dd
�fddpifddqifddrifddsifddtifdduifddvddifddwddifddxddifddyddifddzifdd{ifdd|ifd d}ifd!d~ifd#difd$d�ifd%d�ifd&d�ifd'd�ifd)d�ifd*d�ddifd*d�ddifd,d�ifd.d�ifd0d�ifd1d�ifd2d�ifd3d�ddifd3d�ddifd4d�ifd6d�ifd7d�ddifd7d�ddifd8d�ifd8d�ddifd8d�ddifd9d:d;ififd<d�ifd>d�ifg*eed?dd@dAdBdCdDdEdFdGdHdIdJdKdLd*d3dMdNd4d6d7dOdPdQdRdSgfgd;igd;��Zee�\ZZZdTdU�eej �D�e!e�Z"e"�s�t#�ej$eedV�dWdX��Z%dYdej&dZgfd[d\ej&d]gfd^ej&ej&ej&gfd^gfd_dej&d=gfgZ'ee'�\ZZej$e'edV�d`da��Z(Gdbdc�dc�Z)ddde�Z*ej+j,dfdd=dgfdddgfd!ddgfd1d=dgfg�dgdh��Z-ej+j,dfdDdddgfdBdddgfdAdddgfdDdddgfg�didj��Z.dkdl�Z/ej+j,dme0eej1ejej
g�dndo��Z2dS)��)�datetime�	timedeltaN)�randint)�lib)�	DataFrame�Index�
MultiIndex�Series�concat�isna�notnacCs(t|t�rtj||�ntj||�dS)N)�
isinstancer	�tm�assert_series_equal�assert_index_equal)�left�right�r�;/tmp/pip-build-5_djhm0z/pandas/pandas/tests/test_strings.py�assert_series_or_index_equals
r�cat�sep�,Zzyxr)r�join�center�
�contains�a�count�decode�UTF-8�encode�endswith�naTF�extract�([a-z]*)�expand�
extractall�find�findall�get�index�r�ljust�match�	fullmatch�	normalize�NFC�pad�	partition� �repeat��replace�z�rfind�rindex�rjust�
rpartition�slice��
slice_replace�split�
startswith�	translate�a�d�wrap��zfill�
capitalize�get_dummies�isalnum�isalpha�	isdecimal�isdigit�islower�	isnumeric�isspace�istitle�isupper�len�lower�lstrip�rsplit�rstrip�strip�swapcase�title�upper�casefoldcCsh|]}|jd�s|�qS)�_)rA)�.0�frrr�	<setcomp>msr`)�params�idscCs|jS)a�
    Fixture for all public methods of `StringMethods`

    This fixture returns a tuple of the method name and sample arguments
    necessary to call the method.

    Returns
    -------
    method_name : str
        The name of the method in `StringMethods`
    args : tuple
        Sample values for the positional arguments
    kwargs : dict
        Sample values for the keyword arguments

    Examples
    --------
    >>> def test_something(any_string_method):
    ...     s = pd.Series(['a', 'b', np.nan, 'd'])
    ...
    ...     method_name, args, kwargs = any_string_method
    ...     method = getattr(s.str, method_name)
    ...     # will not raise
    ...     method(*args, **kwargs)
    )�param)�requestrrr�any_string_methodssre�string�c�bytes�a�c�emptyz
mixed-integercCs |j\}}tj|td�}||fS)aA
    Fixture for all (inferred) dtypes allowed in StringMethods.__init__

    The covered (inferred) types are:
    * 'string'
    * 'empty'
    * 'bytes'
    * 'mixed'
    * 'mixed-integer'

    Returns
    -------
    inferred_dtype : str
        The string for the inferred dtype from _libs.lib.infer_dtype
    values : np.ndarray
        An array of object dtype that will be inferred to have
        `inferred_dtype`

    Examples
    --------
    >>> import pandas._libs.lib as lib
    >>>
    >>> def test_something(any_allowed_skipna_inferred_dtype):
    ...     inferred_dtype, values = any_allowed_skipna_inferred_dtype
    ...     # will pass
    ...     assert lib.infer_dtype(values, skipna=True) == inferred_dtype
    ...
    ...     # constructor for .str-accessor will also pass
    ...     pd.Series(values).str
    )�dtype)rc�np�array�object)rd�inferred_dtype�valuesrrr�!any_allowed_skipna_inferred_dtype�s 
rrc@sdeZdZdd�Zdd�Zejjdedg�dd��Z	ejjdedg�d	d
��Z
dd�Zd
d�Zdd�Z
dd�Zdd�Zejjddeeg�dd��Zdd�Zdd�Zejjdddg�ejjdd dg�ejjd!d dg�d"d#����Zejjd$d%d&d'gd(d)d*gd%d&d+ggd,d-d.gd/�ejjd0eeed1d2�gd3d4d5d6gd/�d7d8���Zd9d:�Zejjd;d<d=d>d?g�d@dA��Zejjd;d<d=d>d?g�dBdC��ZdDdE�ZdFdG�ZdHdI�ZdJdK�ZdLdM�ZdNdO�Z ejjdddg�ejjdPde!j"e#j$g�ejjdQdRdSg�dTdU����Z%ejjdddg�ejjdPde!j"e#j$g�ejjdQdRdSg�dVdW����Z&dXdY�Z'dZd[�Z(d\d]�Z)d^d_�Z*d`da�Z+dbdc�Z,ddde�Z-dfdg�Z.dhdi�Z/djdk�Z0dldm�Z1dndo�Z2dpdq�Z3drds�Z4dtdu�Z5dvdw�Z6dxdy�Z7dzd{�Z8d|d}�Z9d~d�Z:d�d��Z;d�d��Z<d�d��Z=ejjd�g�d$fg�d%fg�d&fg�d'fd�d�d�g�d(fd�d�d�g�d)fd�d�d�g�d*fd�d�d�g�d+fg�d�d���Z>d�d��Z?d�d��Z@d�d��ZAd�d��ZBd�d��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQejjd�d�d�d�d�d�g�d�d���ZRd�d��ZSd�d��ZTd�d��ZUd�dÄZVd�dńZWd�dDŽZXd�dɄZYd�d˄ZZd�d̈́Z[d�dτZ\d�dфZ]d�dӄZ^d�dՄZ_d�dׄZ`d�dلZad�dۄZbd�d݄Zcd�d߄Zdd�d�Zed�d�Zfd�d�Zgd�d�Zhejjd�d&d�ded�d�e!j"d�g�fd�d'�d,edde!j"dg�fdd�d-ed�d�e!j"d�g�fd'd�d&ed�d�e!j"d�g�fd'd�d.ed�d�e!j"d�g�fg�d�d���Zid�d��Zjd�d��Zkd�d��Zld��d�Zm�d�d�Zn�d�d�Zo�d�d�Zpejj�deqee!jrg��d�d	��Zs�d
�d�Zt�d�d
�Zu�d�d�Zv�d�d�Zw�d�d�Zx�d�d�Zy�d�d�Zz�d�d�Z{�d�d�Z|�d�d�Z}�d�d�Z~�d �d!�Z�d"�d#�Z�dS(/�TestStringMethodscCs,tjtjkst�ttdg�jtj�s(t�dS)Nr,)r	�str�strings�
StringMethods�AssertionErrorr
)�selfrrr�test_api�szTestStringMethods.test_apic
CsJtjdddgg�}d}tjt|d��|jWdQRXt|d�sFt�dS)Nr�brgz5Can only use .str accessor with Index, not MultiIndex)r.rt)rZfrom_arrays�pytest�raises�AttributeErrorrt�hasattrrw)rx�mi�msgrrr�test_api_mi_raises�s
z$TestStringMethods.test_api_mi_raisesrl�categoryc

Cs||}|\}}|||d�}ddddddg}||krDt|jtj�sxt�n4d}	tjt|	d	��|jWdQRXt|d
�sxt�dS)N)rlrf�unicoderkrh�mixedz
mixed-integerz/Can only use .str accessor with string values.*)r.rt)	r
rtrurvrwr{r|r}r~)
rx�index_or_seriesrlZany_skipna_inferred_dtype�boxrprq�tZtypes_passing_constructorr�rrr�test_api_per_dtype�sz$TestStringMethods.test_api_per_dtypec
CsP|}|\}}|\}	}
}d}|tkrn|jdkrn|	dkrF|jdd�rFd}q�|	dkr`|jdd�r`d}q�|	d	kr�d
}n$|tkr�|dkr�|tkr�|	d	kr�d
}|dk	r�tjj|d�}
|jj|
�|||d
�}t	|j
|	�}|	dk}|	dk}dddgdg|ddg|}||k�r||
|�n:d|	�dt|��d�}tjt
|d��||
|�WdQRXdS)Nrr3r<r&Tz#Method cannot deal with empty Indexr@z,Split fails on empty Series when expand=TruerIz(Need to fortify get_dummies corner casesrk)�reason)rlrr*rSr=rrfr�rhr�z
mixed-integerzCannot use .str.z with values of inferred dtype �.)r.)r3r<)rr*rSr=)r)r�sizer*ror{�markZxfail�nodeZ
add_marker�getattrrt�reprr|�	TypeError)rxr�rlrrrerdr�rprq�method_name�args�kwargsr�r�r��methodZ
bytes_allowedZ
mixed_allowedZ
allowed_typesr�rrr�test_api_per_method�s8
 
z%TestStringMethods.test_api_per_methodc	Cs�ttd��}|d|}|jd�}t|jtj�s4t�|\}}}t|j|�||�}t|j|�||�}t|t	�rzt
j||�n$t|t�r�t
j||�n||ks�t�dS)NZaabbr4r�)
r	�list�astyper
rtrurvrwr�rr�assert_frame_equalr)	rxre�srgr�r�r��result�expectedrrr�test_api_for_categorical.s



z*TestStringMethods.test_api_for_categoricalcCs�d}t|�}tjt��XxP|jD]F}t|t�s2t�tj|j|j�x"|D]}t|t�sHt	|�sHt�qHWq WWdQRX|j
�jj�dks�t�dS)N�google�	wikimedia�	wikipedia�
wikitravel�l)r�r�r�r�)
r	r�assert_produces_warning�
FutureWarningrtr
rwrr+r�dropnarq�item)rx�strs�dsr��elrrr�	test_iterBs
(zTestStringMethods.test_iterc
Cs^tgtd�}d\}}tjt��xt|j�D]\}}q,WWdQRX|dksNt�|dksZt�dS)N)rlrDr>)rDr>)r	rorr�r��	enumeratertrw)rxr��ir�rrr�test_iter_emptyYsz!TestStringMethods.test_iter_emptyc
CsRtdg�}tjt��xt|j�D]\}}q"WWdQRX|sBt�tj||�dS)Nr)r	rr�r�r�rtrwr)rxr�r�r�rrr�test_iter_single_elementgs

z*TestStringMethods.test_iter_single_elementc
Cshtdd�td�D��}d\}}tjt��xt|j�D]\}}q6WWdQRX|dksXt�|dksdt�dS)NcSs"g|]}tdtd�tdd���qS)Nr�)r=r)r^r]rrr�
<listcomp>rszATestStringMethods.test_iter_object_try_string.<locals>.<listcomp>�rD�h)rDr�)r	�rangerr�r�r�rtrw)rxr�r�r�rrr�test_iter_object_try_stringqsz-TestStringMethods.test_iter_object_try_string�otherNcCsH|}ddg}|r||�}n|}||dd�jj|dd�}|jdksDt�dS)Nrrz�name)r�r)r)rtrr�rw)rxr�r�r�rqr�rrr�test_str_cat_name}s
z#TestStringMethods.test_str_cat_namec	CsD|}|dddddtjg�}|jj�}d}||ks4t�|jjdd�}d}||ksRt�|jjdd	d
�}d}||ksrt�tjdtjddd
tjgtd�}|ddddddg�}|jj|dd�}t||�|jjt|�dd�}t||�d}t	dddg�}t
jt|d��|jj|j
�WdQRXt
jt|d��|jjt|��WdQRXdS)NrrzrgZaabbc�-)�na_repzaabbc-r]�NA)rr�Za_a_b_b_c_NA�d�foo)rl�aaza-�bbZbdZcfooz--z<If `others` contains arrays or lists \(or other list-likes.*�1�2�3)r.)rm�nanrtrrwrnrorr�r	r{r|�
ValueErrorrq)	rxr�r�r�r�r�r��rgxr8rrr�test_str_cat�s.


zTestStringMethods.test_str_catcCsh|}|ddddg�}d}tjt|d��|jjd�WdQRXtjt|d��|jjd�WdQRXdS)	Nrrzrgr�z'Did you mean to supply a `sep` keyword?)r.�|z    )r{r|r�rtr)rxr�r�r��messagerrr�#test_str_cat_raises_intuitive_error�sz5TestStringMethods.test_str_cat_raises_intuitive_errorrr,�dtype_targetro�dtype_callerc
Cs.|}tddddg|d�}|tkr$|n
t||d�}tddddg|d�}tdddd	g�}|tkr`|n
t||d�}|jj|j|d
�}	t|	|�t|j|d�}|jj||d
�}	t|	|�|jj|j|d
�}	t|	|�t|j|jd�}tdddddg�}|tkr�|nt||jdd�d�}|jj||d
�}	t|	|�dS)Nrrz)rl)r+rg�abr�r��ac)rr>)rr	rtrrqr)
rxr�r�r�rr�r�r�r�r�rrr�test_str_cat_categorical�s$


"z*TestStringMethods.test_str_cat_categorical�datar>rFr6g�������?g�������?g333333�?rzZintegersZfloatsr�)rbr�cCstj|td�S)N)rl)rmrnro)�xrrr�<lambda>�szTestStringMethods.<lambda>r	rr�znp.arraycCsJtdddg�}||�}d}tjt|d��|jj|ddd�WdQRXdS)	Nrrzrgz;Concatenation requires list-likes containing only strings.*)r.�outerr�)rr�)r	r{r|r�rtr)rxr�r�r�r�r�rrr�test_str_cat_wrong_dtype_raises�s

z1TestStringMethods.test_str_cat_wrong_dtype_raisescRCs�|}tddddg�}|tkr |n
t||d�}tdddd	g|jd�}t|t||d�gd
d�}tdd
ddg�}|tkrv|nt|j|jd�}|jj|�}t||�|jj|j�}t||�|jj||g�}t||�|jj||jg�}t||�ddddg|_|ddddg�}|tk�r|nt|j|jd�}|jj||g�}t||�|jj||jg�}t||�ddddg|_|ddddg�}|tk�r�|nt|j|jd�}|jj|�}t||�d}tdddg�}	t|	|	gd
d�}
tj	t
|d��|jj|
j�WdQRXtj	t
|d��|jj|	j|jg�WdQRXtj	t
|d��|jj|	j|g�WdQRXd}tdtjddg�}tj	t
|d��|jj|dg�WdQRXtj	t
|d��|jj||g�WdQRXtj	t
|d��|jj||jg�WdQRXtj	t
|d��|jj|||gg�WdQRXtj	t
|d��|jjt|��WdQRXtj	t
|d��|jj|t|�g�WdQRXtj	t
|d��|jjd
�WdQRXtj	t
|d�� |jjt|jt|�g��WdQRXdS)Nrrzrgr�)r+�A�B�C�Dr>)�axisZaAaZbBbZcCcZdDdZaDaZbAbZcBcZdCdZaDdZbAaZcBbZdCcz<If `others` contains arrays or lists \(or other list-likes.*r�r�r�)r.z*others must be Series, Index, DataFrame,.*�u)rr	rqr
rtrrr+r{r|r�rmr�r��set�iterr�)rxr�r�r�r�r�r�r�r�r8�er�rrr�test_str_cat_mixed_inputs�sl






z+TestStringMethods.test_str_cat_mixed_inputsrrr��innerrc
Cs�|}tddddgddddgd�}tdddd	gddd
dgd�}|j||d�\}}|jj|dd
�}|tkr~t|�}t|�}t|�}|jj||dd�}	t|	|�dS)Nrrzrgr�)r+r�r��Er�r�)rr�)r�)rr�)r	Zalignrtrrr)
rxr�rr�r�r��sa�tar�r�rrr�test_str_cat_align_indexed\sz,TestStringMethods.test_str_cat_align_indexedcCs�tddddg�}tddddgdddd	gd
�}t||gd	d�}tdd
dddg�}|j|jj|j|d�}|jj||g|dd�}tj||�|jj||dd�}tj||�t	j
ddddg�}tdddddg�}|dkr�|j|j@n
|j|jB}	|j|jj|	|d�}|jj||g|dd�}tj||�tjt
dd��|jj|t|�g|d �WdQRXd!}
td"d#d$g�j}tjt|
d��|jj||d �WdQRXtjt|
d��|jj||g|d �WdQRXdS)%Nrrzrgr�r�r6rr�r>)r+)r��aaa�bbbzc--�dddz-ee)�howr�)rr�r�r�r�r�ZaaAZbbBzc-CZddDz-e-r�zothers must be Series,.*)r.)rz<If `others` contains arrays or lists \(or other list-likes.*r�r�r�)r	r
�locr+rrtrrrrmrnr{r|r�r�rqr�)rxrr�r�r�Zexpected_outerr�r�r�Zrhs_idxr�r8rrr�test_str_cat_align_mixed_inputsos. "z1TestStringMethods.test_str_cat_align_mixed_inputsc	Cs�|}|}tddddg�}|tkr$|n
t||d�}|tjgdtd�}|tkrP|n
t||d�}|tkr~ttjgd|jtd�}nttjgdtd�}|jj|d	d
�}t||�|tkr�ttjgdt|jd�}|jj|d	d
�}t	j
||�dS)Nrrzrgr�)r+r�)rl)r+rlr)r)rlr+)rr	rmr�ror+rtrrrr)	rxr�Zindex_or_series2r�r�r�r�r�r�rrr�test_str_cat_all_na�s
z%TestStringMethods.test_str_cat_all_nacCs�tddddg�}tddddgdddd	gd
�}tddd
ddg�}|jjt||jg�ddd�}tj||�tddgddgd
�}|jj|jdg|jdggddd�}tj||�dS)Nrrzrgr�r�r6rr�r>)r+r�r�zc-cr�z-e-r�r�)rr�zaa-zd-dr)r	rtrr�rqrrr�)rxr�r�r�r�rrr�test_str_cat_special_cases�s&z,TestStringMethods.test_str_cat_special_casescCs�ttjddgdddggddgd�d	�}|j�}||jdk}|jjd
�}|jjd
�}|jj|dd�}|j	dd
ksvt
�|jj||gdd�}|j	ddks�t
�dS)Ni�i�r>rFr6�year�month)�names)r+rtr4)rz2011 2z2011 2 2)rrZfrom_productZreset_indexr�r�r�rtrr�rw)rxZdfZstr_yearZ	str_monthZstr_bothZstr_multiplerrr�test_cat_on_filtered_index�s z,TestStringMethods.test_cat_on_filtered_indexc
Cs>tjddtjdgtjd�}tj|d�}tjddtjdg�}tj||�t|�j	j
d�}tddtjdg�}t|t�svt�tj
||�tjd	tjd
dtj�ddddg	td�}tj|d	�}tjdtjd
tjtjd
tjtjtjg	�}tj||�t|�j	j
d	�}tdtjd
tjtjd
tjtjtjg	�}t|t��s.t�tj
||�dS)Nr�ZfoofooZfoooofooofommmfoo)rlzf[o]+r>rFr�rrzTg@r)rmrnr��object_ruZ	str_countr�assert_numpy_array_equalr	rtrr
rwrr�todayro)rxrqr��expr��rs�xprrr�
test_count�s&(&zTestStringMethods.test_countc
Cs�tjdtjdddgtjd�}d}tj||�}tjdtjdddgtjd�}tj||�tj||dd	�}tjdtjdddgtjd�}tj||�tjdd
ddgtd�}tj||�}tjddddg�}|j	tj
ks�t�tj||�tjddd
dgtd�}tj|ddd�}tjddddg�}tj||�tj|dddd�}tjddddg�}tj||�tjdtjddtj
�ddddg	td�}tj|d�}tjdtjdtjtjdtjtjtjg	tjd�}tj||�t|�jjd�}tdtjdtjtjdtjtjtjg	�}t|t��st�tj||�tjdtjddgtjd�}d}tj||�}tjdtjddgtjd�}tj||�tj||dd�}tjddddg�}tj||�tjdd
ddgtjd�}tj||�}tjddddg�}|j	tj
k�s�t�tj||�dS)Nr�Zfooommm__fooZmmm_z
foommm[_]+bar)rlzmmm[_]+FT)�regexZxyz�FooZxYzZfOOomMm__fOoZMMM_zFOO|mmm)�case)r�r�rrzr>g@�o)r#)rmrnr�r�ruZstr_containsrr�rorl�bool_rwrr�r	rtrr
r)rxrq�patr�r�r�r�r�rrr�
test_contains�s^ 
$zTestStringMethods.test_containscCs�tddddtjgdd�}|jjddd�}tdddddg�}tj||�|jjddd�}tdddddg�}tj||�tddddtjg�}|jjddd�}tdddddg�}tj||�|jjddd�}tdddddg�}tj||�dS)	Nrrzrgr�)rlT)r#F)r	rmr�rtrrr)rxrqr�r�rrr�!test_contains_for_object_category6sz3TestStringMethods.test_contains_for_object_category�
null_valuer#TFc

CsBtd|ddd|dg|d�}|jjd�}tdtjdddtjdg�}tj||�|jjd|d	�}td|ddd|dg�}tj||�tjd
tjddtj	�dddd
g	tj
d�}tj|d�}tjdtjdtjtjdtjtjtjg	tj
d�}	tj
||	�t|�jjd�}t|t��st�tdtjdtjtjdtjtjtjg	�}	tj||	�dS)N�om�foo_nom�nom�bar_foor�)rlFT)r#rrzr>g@r_)r	rtrArmr�rrrnrr�r�ruZstr_startswithr�r
rw)
rxrlr�r#rqr�r�r�r�r�rrr�test_startswithMs,
 
$z!TestStringMethods.test_startswithc

Cs@td|ddd|dg|d�}|jjd�}tdtjdddtjdg�}tj||�|jjd|d	�}td|ddd|dg�}tj||�tjd
tjddtj	�dddd
g	t
d�}tj|d�}tjdtjdtjtjdtjtjtjg	tj
d�}	tj||	�t|�jjd�}tdtjdtjtjdtjtjtjg	�}	t|t��s0t�tj||	�dS)Nr�r�r�rr�)rlFT)r#rrzr>g@r_)r	rtr"rmr�rrrnrr�roruZstr_endswithr�r�r
rw)
rxrlr�r#rqr�r�r�r�r�rrr�
test_endswithrs, 
$zTestStringMethods.test_endswithc
Cs�tddtjddg�}|jj�}tddtjddg�}tj||�tdtjdd	tj�d
dddg	�}|jj�}tdtjdtjtjdtjtjtjg	�}tj	||�dS)
N�FOO�BAR�Blah�blurgr��Bar�Blurg�barT�blahr>g@)
r	rmr�rtrZrrrr��assert_almost_equal)rxrqr�r�r�rrr�
test_title�s

$zTestStringMethods.test_titlec
Cs�tdtjddg�}|jj�}tdtjddg�}tj||�|jj�}tj||�tdtjddtj	�ddd	d
g	�}|jj�}t|�jj�}tdtjdtjtjdtjtjtjg	�}t
|t�s�t�tj||�dS)Nr�r�ZOMZNOMrrzTr�r>g@)r	rmr�rtr[rrrTrr�r
rw)rxrqr�r�r�r�r�rrr�test_lower_upper�s

 
&z"TestStringMethods.test_lower_upperc
Cs�tddtjddg�}|jj�}tddtjddg�}tj||�tdtjdd	tj�d
dddg	�}|jj�}tdtjdtjtjdtjtjtjg	�}tj	||�dS)
Nrrrrr�rrr	Tr
r>g@)
r	rmr�rtrHrrrr�r)rxrqr�r�r�rrr�test_capitalize�s

$z!TestStringMethods.test_capitalizec
Cs�tddtjddg�}|jj�}tddtjddg�}tj||�tdtjdd	tj�ddd
dg	�}|jj�}tdtjdtjtjdtjtjtjg	�}tj	||�dS)Nrrrrr�r	ZbLAHZBLURGTr>g@)
r	rmr�rtrYrrrr�r)rxrqr�r�r�rrr�
test_swapcase�s

$zTestStringMethods.test_swapcasecCs�dddddg}t|�}|jj�j�dd�|D�ks6t�|jj�j�dd�|D�ksVt�|jj�j�d	d�|D�ksvt�|jj�j�d
d�|D�ks�t�|jj�j�dd�|D�ks�t�dS)Nr�r�ZCCCZDdddZeEEEcSsg|]}|j��qSr)rT)r^�vrrrr��sz6TestStringMethods.test_casemethods.<locals>.<listcomp>cSsg|]}|j��qSr)r[)r^rrrrr��scSsg|]}|j��qSr)rZ)r^rrrrr��scSsg|]}|j��qSr)rH)r^rrrrr��scSsg|]}|j��qSr)rY)r^rrrrr��s)	r	rtrT�tolistrwr[rZrHrY)rxrqr�rrr�test_casemethods�s    z"TestStringMethods.test_casemethodsc
Cs�tdtjg�}|jjdd�}tdtjg�}tj||�|jjdddd�}tdtjg�}tj||�tdtjd	d
tj�ddddg	�}t|�jjdd�}td
tjdtjtjdtjtjtjg	�}t	|t�s�t
�tj||�tdjd�g�}tdjd�g�}|jjddt
jd�}tj||�d}x~ttfD]r}xjddd
difD]X}	xPd
ddgd
dddgfD]6}
||
�}tjt|d��|jjd
|	�WdQRX�qRW�q6W�q"WdS)N�fooBAD__barBADzBAD[_]*r,�foobarr>)�n�	foobarBAD�aBAD�bBADT�fooBADg@rrzr�sabcd,àzutf-8sabcd, àz(?<=\w),(?=\w)z, )�flagsz!repl must be a string or callabler6rg�ad)r.)r	rmr�rtr7rrrr�r
rwrr�re�UNICODErr{r|r�)rxrqr�r�r�r�r�r��klass�replr�rrr�test_replace�s0&zTestStringMethods.test_replacecCstdtjg�}dd�}|jjd|dd�}tdtjg�}tj||�d}d	d�}tjt	|d
��|jjd|�WdQRXdd�}tjt	|d
��|jjd|�WdQRXdd
d�}tjt	|d
��|jjd|�WdQRXtdtjg�}d}dd�}|jj||�}tdtjg�}tj||�dS)NrcSs|jd�j�S)Nr)�grouprY)�mrrrr�sz9TestStringMethods.test_replace_callable.<locals>.<lambda>z
[a-z][A-Z]{2}rF)r�foObaD__baRbaDzO((takes)|(missing)) (?(2)from \d+ to )?\d+ (?(3)required )positional arguments?cSsdS)Nrrrrrr�s)r.rcSsdS)Nr)r"r�rrrr�scSsdS)Nr)r"r��yrrrr�szFoo Bar Bazz,(?P<first>\w+) (?P<middle>\w+) (?P<last>\w+)cSs|jd�j�S)NZmiddle)r!rY)r"rrrr�&sZbAR)N)
r	rmr�rtr7rrr{r|r�)rxrqrr�r�Zp_errr�rrr�test_replace_callables*
z'TestStringMethods.test_replace_callablec	Cstdtjg�}tjd�}|jj|d�}tdtjg�}tj||�|jj|ddd�}tdtjg�}tj||�tdtjd	d
t	j
�ddddg	�}t|�jj|d�}td
tjdtjtjdtjtjtjg	�}t|t�s�t�tj
||�tdjd�g�}tdjd�g�}tjdtjd�}|jj|d�}tj||�tdtjg�}tjd�}tjtdd��|jj|dtjd�}WdQRXtjtdd��|jj|ddd�}WdQRXtjtdd��|jj|dd
d�}WdQRXtdtjg�}dd�}tjd�}|jj||dd�}tdtjg�}tj||�dS) NrzBAD[_]*r,rr>)rrrrTrg@rrzr�sabcd,àzutf-8sabcd, àz(?<=\w),(?=\w))rz, ZfooBAD__barBAD__badzcase and flags cannot be)r.F)r�cSs|jd�j�S)Nr)r!rY)r"rrrr�Zsz?TestStringMethods.test_replace_compiled_regex.<locals>.<lambda>z
[a-z][A-Z]{2}rFr#)r	rmr�r�compilertr7rrrr�r
rwrrrr{r|r��
IGNORECASE)	rxrqr�r�r�r�r�r�rrrr�test_replace_compiled_regex+sB
&

z-TestStringMethods.test_replace_compiled_regexcCs�tddtjg�}tddtjg�}|jjdd�}tj||�tddtjg�}|jjdddd�}tj||�dd	�}tjd
�}d}t	j
t|d��|jjd
|dd�WdQRXd}t	j
t|d��|jj|ddd�WdQRXdS)Nzf.or�Zbaozf.�baF)r�cSs|jd�j�S)Nr)r!rY)r"rrrr�msz8TestStringMethods.test_replace_literal.<locals>.<lambda>z
[a-z][A-Z]{2}z2Cannot use a callable replacement when regex=False)r.�abczCCannot use a compiled regex as replacement pattern with regex=Falser,)r	rmr�rtr7rrrr&r{r|r�)rxrqr�r�Z
callable_replZcompiled_patr�rrr�test_replace_literal`s
z&TestStringMethods.test_replace_literalc
Cs�tddtjdtjdg�}|jjd�}tddtjdtjd	g�}tj||�|jjd
dddd
dg�}tddtjdtjdg�}tj||�tdtjddtj�ddd
dg	�}t|�jjd�}tdtjdtjtjdtjtjtjg	�}t	|t�s�t
�tj||�dS)Nrrzrgr�r6r�r��cccr�r>rFr���r��ccccZddddddTr�g@Z	foofoofoo)r	rmr�rtr5rrrr�r
rw)rxrqr�r�r�r�r�rrr�test_repeatxs $zTestStringMethods.test_repeatcCs|tddgdd�}|jjddg�}tddgdd�}tj||�tddgdd�}|jjddg�}tddgdd�}tj||�dS)Nrrf)rlr6r�r�rz)r	rtr5rr)rxrqr�r�rrr�test_repeat_with_null�sz'TestStringMethods.test_repeat_with_nullc
CsTtdtjdg�}|jjd�}tdtjdg�}tj||�tddtjdg�}|jjd�}tddtjdg�}tj||�tdtjd	dtj�ddd
dg	�}t|�jjd�}tdtjdtjtjdtjtjtjg	�}t	|t�s�t
�tj||�tdd
tjg�jjddd�}tdddg�}tj||�tdd
tjg�jjd�}tdtjtjg�}tj||�dS)Nrr�z.*(BAD[_]+).*(BAD)TF�BAD_BADleroybrownz.*BAD[_]+.*BAD�aBAD_BAD�	BAD_b_BADr>g@rr)r#)r	rmr�rtr.rrrr�r
rw)rxrqr�r�r�r�r��resrrr�
test_match�s8&zTestStringMethods.test_matchcCs�tddtjdg�}|jjd�}tddtjdg�}tj||�tddtjdgdd�}|jjd�}tddtjdgd	d�}tj||�dS)
Nrr2r�z.*BAD[_]+.*BADTFrf)rl�boolean)r	rmr�rtr/rr)rxrqr�r�Z
string_valuesZ
string_exprrr�test_fullmatch�sz TestStringMethods.test_fullmatchcCs>tdtjdg�}tjtdd��|jjddd�WdQRXdS)Nrr�zexpand must be True or False)r.z.*(BAD[_]+).*(BAD))r&)r	rmr�r{r|r�rtr$)rxrqrrr�test_extract_expand_None�sz*TestStringMethods.test_extract_expand_NonecCsJtdtjdg�}|jjd�}t|t�s*t�|jjddd�}tj	||�dS)Nrr�z
.*(BAD[_]+).*T)r&)
r	rmr�rtr$r
rrwrr�)rxrqZresult_unspecifiedZresult_truerrr�test_extract_expand_unspecified�s
z1TestStringMethods.test_extract_expand_unspecifiedcCs:tdtjdg�}tjtjg}|jjddd�}tddg||g�}tj||�tdtjd	d
tj	�ddddg	�}t|�jjddd�}td
dg|d
dg||||||g	�}tj||�tdtjdg�}|jjddd�}tddg||g�}tj||�t
dddddg�}tjt
dd��|jjddd�WdQRXx�tt
gD]�}|dddg�}	d}
tjt
|
d��|	jjddd�WdQRXtjt
|
d��|	jjddd�WdQRX|ddg�}	|	jjddd�}|jdk�s�t�|ddgdd�}|tk�r�tj||�ntj||��q0Wtdddg�}|jjddd�}ttjtjtjgtd �}tj||�|jjd!dd�}ttjtjgtjtjgtjtjggtd �}tj||�|jjd"dd�}tdd#tjg�}tj||�|jjddd�}tdd$gd#d%gtjtjgg�}tj||�|jjd&dd�}tdd#tjgd'd�}tj||�|jjd(dd�}tdd$gd#d%gtjtjggd'd)gd*�}tj||�|jjd+dd�}tdd$gd#d%gtjtjggd,d)gd*�}tj||�|jjd-dd�}tdd#tjg�}tj||�td.d/d0g�jjd1dd�}tdd$gd#d%gtjtjgg�}tj||�tddd2g�jjd3dd�}tdd$gd#d%gtjd2ggd'd)gd*�}tj||�tddd4g�jjd5dd�}tdd$gd#d%gd4tjggd'd)gd*�}tj||�d6d7�}tjtjtjtjtjtjg}
x|
D]}||���q�Wtd8d9d:gd;d�}|jjd<dd�}td=d>d?gd@d�}tj||�|j|jk�s6t�dS)ANrr�z.*(BAD[_]+).*(BAD)F)r&�BAD__�BADr3r4Tr>g@�BAD_�A1�A2�A3ZA4ZB5�	supported)r.z
([AB])([123])�B2�C3z"pattern contains no capture groupsz
[ABC][123]z
(?:[AB]).*z(?P<uno>A)\d�unor�)r�z(_))rlz(_)(_)z([AB])[123]r�r�r�z(?P<letter>[AB])�letterz!(?P<letter>[AB])(?P<number>[123])�number)�columnsz([AB])(?P<number>[123])rz([AB])(?:[123])�A11�B22�C33z([AB])([123])(?:[123])r�z"(?P<letter>[AB])?(?P<number>[123])r�z#(?P<letter>[ABC])(?P<number>[123])?cSs�dddg}|dt|��}t||d�}|jjddd�}tdd	tjg|d�}tj||�t||d�jjd
dd�}ddgdd	gdtjgg}t|d
dg|d�}tj	||�dS)Nr>rBr�)r+z(\d)F)r&r�r�z(?P<letter>\D)(?P<number>\d)?r�r�rErF)rGr+)
rSr	rtr$rmr�rrrr�)r+r�r�r�r��e_listrrr�check_indexgs

z@TestStringMethods.test_extract_expand_False.<locals>.check_index�a3�b3�c2Zbobz(?P<sue>[a-z])rrzrgZsue)r	rmr�rtr$rrr�rr�rr{r|r�r�rwrrro�makeStringIndex�makeUnicodeIndex�makeIntIndex�
makeDateIndex�makePeriodIndex�makeRangeIndex)rxrq�err�r�r�r��idxr�s_or_idxr�r�rL�i_funsr+�rr�rrr�test_extract_expand_False�s�"
($$

"
"
z+TestStringMethods.test_extract_expand_FalsecCsttdtjdg�}tjtjg}|jjddd�}tddg||g�}tj||�tdtjd	dtj	�ddd
dg	�}t|�jjddd�}tddg|ddg||||||g	�}tj||�x�tt
gD]�}|d
ddg�}d}	tjt
|	d��|jjddd�WdQRXtjt
|	d��|jjddd�WdQRX|d
dg�}|jjddd�}
t|
t��sLt�|
d}tj|tddgdd��q�WdS)Nrr�z.*(BAD[_]+).*(BAD)T)r&r;r<r3r4r>g@r=r>rBrCz"pattern contains no capture groups)r.z
[ABC][123]z
(?:[AB]).*r?z(?P<uno>A)\drDr�)r�)r	rmr�rtr$rrr�rr�rr{r|r�r
rwr)rxrqrVr�r�r�r�rrXr�Z	result_dfZ
result_seriesrrr�test_extract_expand_True�s<"z*TestStringMethods.test_extract_expand_TruecCs��x�dD�]�}tdddg|d�}|jjddd�}ttjtjtjgtd	�}tj||�|jjd
dd�}ttjtjgtjtjgtjtjggtd	�}tj||�|jjddd�}tdd
tjg�}tj||�|jjddd�}tddgd
dgtjtjgg�}tj||�|jjddd�}tddd
tjgi�}tj||�|jjddd�}ddgd
dgtjtjgg}t|ddgd�}tj||�|jjddd�}t|ddgd�}tj||�|jjddd�}tdd
tjg�}tj||�qWdS)N�series_namer>rBrC)r�z(_)T)r&)rlz(_)(_)z([AB])[123]r�r�z
([AB])([123])r�r�z(?P<letter>[AB])rEz!(?P<letter>[AB])(?P<number>[123])rF)rGz([AB])(?P<number>[123])rz([AB])(?:[123]))Nr])	r	rtr$rrmr�rorr�)rxr]r�r�r�rKrrr�test_extract_series�s8(z%TestStringMethods.test_extract_seriescCs"tdddg�jjddd�}tddgd	d
gtjtjgg�}tj||�tddd
g�jjddd�}ddgd	d
gtjd
gg}t|ddgd�}tj||�tdddg�jjddd�}ddgd	d
gdtjgg}t|ddgd�}tj||�dd�}tjtj	tj
tjtjtj
g}x|D]}||���q
WdS)NrHrIrJz([AB])([123])(?:[123])T)r&r�r�r�r�r>rBr�z"(?P<letter>[AB])?(?P<number>[123])rErF)rGr�z#(?P<letter>[ABC])(?P<number>[123])?cSs�dddg}|dt|��}t||d�jjddd�}tdd	tjg|d�}tj||�t||d�jjd
dd�}ddgdd	gdtjgg}t|d
dg|d�}tj||�dS)Nr>rBr�)r+z(\d)T)r&r�r�z(?P<letter>\D)(?P<number>\d)?r�r�rErF)rGr+)	rSr	rtr$rrmr�rr�)r+r�r�r�rKrrrrLs

zCTestStringMethods.test_extract_optional_groups.<locals>.check_index)r	rtr$rrmr�rr�rPrQrRrSrTrU)rxr�r�rKrLrYr+rrr�test_extract_optional_groups�s.



z.TestStringMethods.test_extract_optional_groupscCsDtdddgdd�}|jjddd�}td	d
ddgi�}tj||�dS)
NrMrNrOr])r�z(?P<letter>[a-z])T)r&rErrzrg)r	rtr$rrr�)rxr�rZr�rrr�'test_extract_single_group_returns_framesz9TestStringMethods.test_extract_single_group_returns_framec
Cs�dddddtjdg}d7d8d9d:d;d<d=d>g}d}dddg}t|�}tjd?d@dAdBdCdDdEdFgdGd�}t|||�}|jj|tj	�}t
j||�tjdHdIdJdKdLdMdNg�}	t||	�}
tjdOdPdQdRdSdTdUdVgdWd�}t|||�}|
jj|tj	�}t
j||�t||	�}dX|j_
dY|_
t|||�}|jj|tj	�}t
j||�dd,d-g}d.}t|�jj|�}tjdZd[d\gd]d�}td^tjd1ftjd2fg|d3d4gd5�}t
j||�d6}t|�jj|�}td_tjd1ftjd2fg|dd4gd5�}t
j||�dS)`Nzdave@google.comztdhock5@gmail.comzmaudelaperriere@gmail.comz'rob@gmail.com some text steve@gmail.comz%a@b.com some text c@d.com and e@f.comr,�daver��com�tdhock5�gmail�maudelaperriere�rob�steverrzrgr�r�r_zq
        (?P<user>[a-z0-9]+)
        @
        (?P<domain>[a-z]+)
        \.
        (?P<tld>[a-z]{2,4})
        �user�domain�tldrr>rFr6r�r.)r��single�Dave�Toby�Maude�multiple�robAndSteve�abcdef�none�missingrk�matches�descriptionr>Z32z"(?P<letter>[AB])?(?P<number>[123])r�r�r�r�rErF)rGz([AB])?(?P<number>[123]))rar�rb)rcrdrb)rerdrb)rfrdrb)rgrdrb)rrzrb)rgr�rb)r�r_rb)rr)r>r)rFr)r6r)r6r>)r�r)r�r>)r�rF)Nr.)rkrl)rkrm)rkrn)rorp)rorq)rrrs)rrrk)rkrlr)rkrmr)rkrnr)rorpr)rorpr>)rorqr)rorqr>)rorqrF)NNr.)rtru)rtrur.)r>r)rFr)rFr>)Nr.)r�r�)r�r�)rmr�r	r�from_tuplesrrtr'r�VERBOSErr�r+r�)
rxZsubject_listZexpected_tuplesZ
named_patternZexpected_columns�SZexpected_indexZexpected_dfZcomputed_dfZseries_indexZSiZSn�patternrrr�test_extractall$s�



z!TestStringMethods.test_extractallcCs�tdddgdd�}|jjd�}tjddddgdd�}tdd
dddgi|�}tj||�|jjd�}td
dddg|�}tj||�dS)NrMrN�d4c2r])r�z(?P<letter>[a-z])rr>rFr.)r�rErrzr�rgz([a-z]))rr)r>r)rFr)rFr>)Nr.)r	rtr'rrvrrr�)rxr�rZr�r�rrr�test_extractall_single_group�sz.TestStringMethods.test_extractall_single_groupcCsVtdddgdd�}|jjd�}tjddddgdd�}tdd
ddg|�}tj||�dS)NZab3Zabc3Zd4cd2r])r�z([a-z]+)rr>rFr.)r�r�r*r�Zcd)rr)r>r)rFr)rFr>)Nr.)r	rtr'rrvrrr�)rxr�rZr�r�rrr�,test_extractall_single_group_with_quantifier�sz>TestStringMethods.test_extractall_single_group_with_quantifierzdata, names�i1�i2rMrNr{c	s8t|��t|�dkr*tt��|dd�}n$�fdd�t��D�}tj||d�}t|d|dd	�}tjg|dd�}|jjd�}tdg|d�}t	j
||�|jjd
�}tddg|d�}t	j
||�|jjd�}tdg|d�}t	j
||�|jjd�}tddg|d�}t	j
||�|jjd�}tddg|d�}t	j
||�dS)Nr>r)r�c3s |]}t|g�d�VqdS)r>N)�tuple)r^r�)rrr�	<genexpr>�sz?TestStringMethods.test_extractall_no_matches.<locals>.<genexpr>)r�r]ro)r�r+rlr.z(z))rGr+z(z)(z)z(?P<first>z)�firstz(?P<first>z)(?P<second>z)�secondz(z)(?P<second>z))r.)rSrr�rrvr	rtr'rrr�)	rxr�r�r�rr��eirZr�r)rr�test_extractall_no_matches�s,z,TestStringMethods.test_extractall_no_matchescCstdddgdd�}|jjd�}tjdddgdd	gd
�}tddd
dgi|d�}tj||�x@tdddg�tdddgdd�gD]}|jjd�}tj||�qzWtdddgdtdddgdd�d�}|jjd�}tjdddgdd	gd
�}tddd
dgi|d�}tj||�dS)NZa1a2Zb1�c1�xxx)r�z[ab](?P<digit>\d)rr>r.)r��digitr�r�)r+Zs_name�XX�yy�zzZidx_name)r�r+)rr)rr>)r>r)r�r)r�r>)r�r)	r	rtr'rrvrrr�r)rxr�r5Zexp_idxr�rWrrr�test_extractall_stringindex�s(z-TestStringMethods.test_extractall_stringindexc	Cs<tdddgdd�}tjtdd��|jjd�WdQRXdS)	NrMrNr{r])r�zno capture groups)r.z[a-z])r	r{r|r�rtr')rxr�rrr�test_extractall_errors�sz(TestStringMethods.test_extractall_errorscCs�tdddgdddgdd�}|jjjd	d
d�}tdd
dg�}tj||�|jjjdd
d�}dddg}t|ddgd�}tj||�dS)NrMrNr{r@ZB3ZD4r])r+r�z([A-Z])T)r&r�r�r�z!(?P<letter>[A-Z])(?P<digit>[0-9])r��4rEr�)rG)r�r�)r�r�)r�r�)r	r+rtr$rrr�)rxr�rZr�rKrrr�!test_extract_index_one_two_groups�s
z3TestStringMethods.test_extract_index_one_two_groupscCs�tdddgdd�}d}|jj|dd�}|jj|�}|jd	d
d�}tj||�d}|jj|dd�}|jj|�}|jd	d
d�}tj||�d
}|jj|dd�}	|jj|�}|jd	d
d�}tj|	|�d}
|jj|
dd�}|jj|
�}|jd	d
d�}tj||�dS)NrMrNrOr])r�z([a-z])([0-9])T)r&rr.)�levelz!(?P<letter>[a-z])(?P<digit>[0-9])z(?P<group_name>[a-z])z([a-z]))r	rtr$r'�xsrr�)rxr��pattern_two_noname�extract_two_nonameZhas_multi_indexZno_multi_index�pattern_two_named�extract_two_named�pattern_one_named�extract_one_named�pattern_one_noname�extract_one_nonamerrr�test_extractall_same_as_extracts*z1TestStringMethods.test_extractall_same_as_extractc
Cstjdddgdd	�}td
ddg|d
d�}d}|jj|dd�}|jj|�}|jddd�}tj||�d}|jj|dd�}|jj|�}|jddd�}tj||�d}	|jj|	dd�}
|jj|	�}|jddd�}tj|
|�d}|jj|dd�}|jj|�}|jddd�}tj||�dS)Nr�r�r�r�r��third�capital�ordinal)r�rMrNrOr])r�z([a-z])([0-9])T)r&rr.)r�z!(?P<letter>[a-z])(?P<digit>[0-9])z(?P<group_name>[a-z])z([a-z]))r�r�)r�r�)r�r�)r�r�)	rrvr	rtr$r'r�rr�)
rxr�r�r�r�Zhas_match_indexZno_match_indexr�r�r�r�r�r�rrr�-test_extractall_same_as_extract_subject_index's0z?TestStringMethods.test_extractall_same_as_extract_subject_indexcCsBttd�}}tdd�}ttd�}ttd�}tj||jj|��d|jj�ksRt�tj||jj��tj||jj	d��tj||jj
d��tj||jjd��tj||jjd��tj||jj
��tj||jj��tj||jjdd��tj||jjd��tj||jjd��tjtdgtd	�|jjd
dd��tjtdd
gtd	�|jjddd��tj||jjd
dd��tjtdd
gtd	�|jjddd��tjttd�|jj��tj||jjd��tj||jj��tj||jjd��tj||jjd��tj||jjd��tj||jjd��tj||jjd��tj||jjd��tj||jjd��tj||jjddd��tj||jj ddd��tj||jj!d
d��tj||jj!d
d��tj||jj"��tj||jj#��tj||jj$��tj||jj%d��tj||jj&d��tj||jj'd��tj||jj(d��tj||jj)��tj||jj*��tj||jj+��tj||jj,��tj||jj-��tj||jj.��tj||jj/��tj||jj0��tj||jj1��tj||jj2��tj||jj3��tj||jj4d��tj5dd�}tj||jj6|��dS)N)rl�int64r,rrzr6z^ar)rGrlz()T)r&r>z()()F�*)�stop)�step�asciir1)7r	ro�boolrrrtrrwrZrrrAr"rTr[r7r5r.r�rr$rIrrSr)r(r9r2rr@rVr3r<r=rXrUrWrEr*rr!rJrKrMrPrNrRrQrOrLrHrYr0�	maketransrB)rxZ	empty_strrkZ	empty_intZ
empty_boolZempty_bytes�tablerrr�test_empty_str_methodsGsv


 z(TestStringMethods.test_empty_str_methodscCs<ttd�}t�}tj||jjd��tj||jjd��dS)N)rlr)r	rtrrr�r3r<)rxrkZempty_dfrrr�test_empty_str_methods_to_frame�s
z1TestStringMethods.test_empty_str_methods_to_framec
Cslddddddddd	d
g
}t|�}ddddddddddg
}ddddddddddg
}ddddddddddg
}ddddddddddg
}ddddddddddg
}ddddddddddg
}ddddddddddg
}	ddddddddddg
}
tj|jj�t|��tj|jj�t|��tj|jj�t|��tj|jj�t|��tj|jj�t|��tj|jj	�t|	��tj|jj
�t|
��|jj�j�d
d�|D�k�s�t�|jj�j�dd�|D�k�s�t�|jj�j�dd�|D�k�s�t�|jj�j�dd�|D�k�st�|jj�j�dd�|D�k�s$t�|jj	�j�dd�|D�k�sFt�|jj
�j�dd�|D�k�sht�dS)Nr�rzZXyr�Z3Ar,ZTTZ55r�z  TFcSsg|]}|j��qSr)rJ)r^rrrrr��sz4TestStringMethods.test_ismethods.<locals>.<listcomp>cSsg|]}|j��qSr)rK)r^rrrrr��scSsg|]}|j��qSr)rM)r^rrrrr��scSsg|]}|j��qSr)rP)r^rrrrr��scSsg|]}|j��qSr)rN)r^rrrrr��scSsg|]}|j��qSr)rR)r^rrrrr��scSsg|]}|j��qSr)rQ)r^rrrrr��s)
r	rrrtrJrKrMrPrNrRrQrrw)rxrqZstr_sZalnum_eZalpha_eZdigit_eZnum_eZspace_eZlower_eZupper_eZtitle_errr�test_ismethods�sB""""""z TestStringMethods.test_ismethodscCs6dddddddg}t|�}dd	d	dd	d	dg}dd	dddd	dg}tj|jj�t|��tj|jj�t|��dddddddg}|jj�j�d
d�|D�ks�t�|jj�j�dd�|D�ks�t�dtj	ddtj	ddg}t|�}dtj	d	dtj	d	dg}dtj	ddtj	d	dg}tj|jj�t|��tj|jj�t|��dS)
Nr�r��¼u★u፸u3ZfourFTcSsg|]}|j��qSr)rO)r^rrrrr��sz4TestStringMethods.test_isnumeric.<locals>.<listcomp>cSsg|]}|j��qSr)rL)r^rrrrr��s)
r	rrrtrOrLrrwrmr�)rxrqr�Z	numeric_eZ	decimal_eZunicodesrrr�test_isnumeric�s  z TestStringMethods.test_isnumericcCs�tddtjg�}|jjd�}tdddgdddgdddggtd�d�}tj||�tdd	d
g�}|jjd�}tdddgdddgdddggtd�d�}tj||�t	ddd
g�}|jjd�}t
jdddgdd�}tj||�dS)Nza|bza|cr�r>rr*)rGza;br��;Z7abzb|crzrg)r�)r>r>r)r>rr>)rr>r>)rrzrg)
r	rmr�rtrIrr�rr�rrrvr)rxr�r�r�rWrrr�test_get_dummies�s((z"TestStringMethods.test_get_dummiescCs�tdddg�}|jjd�}tdddgdddgdddggdddgd�}tj||�td	d
dg�}|jjd�}tjdddgdd�}tj	||�dS)Nrzb,namerzrr>rr�)rGza|bzname|czb|namer�rg)r�)r>r>rr)rrr>r>)rr>rr>)rrzrgr�)
r	rtrIrrr�rrrvr)rxr�r�r�rWrrr� test_get_dummies_with_name_dummy�s(z2TestStringMethods.test_get_dummies_with_name_dummyc
Cs�tddtjdg�}|jjd�jjd�}tj||�tdtjddtj	�ddd	d
g	�}t|�jjd�jjd�}tdtjdtjtjdtjtjtjg	�}t
|t�s�t�tj||�dS)N�a_b_c�c_d_e�f_g_hr]�a_b�
asdf_cas_asdfTr�r>g@)
r	rmr�rtr@rrrrr�r
rwr)rxrqr�r�r�r�rrr�	test_join�s4
zTestStringMethods.test_joinc
Cs�tdddtjdg�}|jj�}|jdd��}tj||�tdtjdd	tj	�ddd
dg	�}t|�jj�}tdtjd
tjtjdtjtjtjg	�}t
|t�s�t�tj||�dS)Nr�ZfoooZfoooooZfooooooocSst|�rt|�StjS)N)rrSrmr�)r�rrrr�$sz,TestStringMethods.test_len.<locals>.<lambda>r�r�Tr>g@r6�
)
r	rmr�rtrS�maprrrr�r
rwr)rxrqr�r�r�r�r�rrr�test_len s$
&zTestStringMethods.test_lenc
Cs�tdtjddg�}|jjd�}tddgtjgdgg�}tj||�tdtjddtj�ddddg	�}t|�jjd�}tddgtjgtjtjdgtjtjtjg	�}t	|t�s�t
�tj||�dS)	Nrr�r<zBAD[_]*r;Tr>g@)r	rmr�rtr)rrrr�r
rw)rxrqr�r�r�r�r�rrr�test_findall<s6
zTestStringMethods.test_findallcCsNtdddddg�}|jjd�}tj|tddd	d
dg��tjdd�|jD�tjd
�}tj	|j|�|jj
d�}tj|tdddddg��tjdd�|jD�tjd
�}tj	|j|�|jjdd�}tj|tdddddg��tjdd�|jD�tjd
�}tj	|j|�|jj
dd�}tj|tdddddg��tjdd�|jD�tjd
�}tj	|j|�|jjddd�}tj|tdddddg��tjdd�|jD�tjd
�}tj	|j|�|jj
ddd�}tj|tdddddg��tjdd�|jD�tjd
�}tj	|j|�tjt
dd��|jjd
�}WdQRXtjt
dd��|jj
d
�}WdQRXdS) N�ABCDEFG�BCDEFEF�	DEFGHIJEF�EFGHEF�XXXX�EFr�r6r>rcSsg|]}|jd��qS)r�)r()r^rrrrr�hsz/TestStringMethods.test_find.<locals>.<listcomp>)rlr-r�cSsg|]}|jd��qS)r�)r9)r^rrrrr�mscSsg|]}|jdd��qS)r�r6)r()r^rrrrr�rscSsg|]}|jdd��qS)r�r6)r9)r^rrrrr�wsr.cSsg|]}|jddd��qS)r�r6r.)r()r^rrrrr�|scSsg|]}|jddd��qS)r�r6r.)r9)r^rrrrr��sz!expected a string object, not int)r.���r�r�r�r�r�r�r�)r	rtr(rrrmrnrqr�r�r9r{r|r�)rxrqr�r�rrr�	test_findds<zTestStringMethods.test_findcCs"tdtjdtjdg�}|jjd�}tj|tdtjdtjd
g��|jjd�}tj|tdtjdtjdg��|jjdd�}tj|tdtjdtjdg��|jjdd�}tj|tdtjdtjd
g��|jjddd	�}tj|tdtjdtjdg��|jjddd	�}tj|tdtjdtjdg��dS)Nr�r�r�r�r�r>r�r6r.r�r�r�r�r�r�r�r�)r	rmr�rtr(rrr9)rxrqr�rrr�
test_find_nan�szTestStringMethods.test_find_nancCs�dd�}�xFttgD�]8}|ddddg�}|jjd�}|||dd	d
dg��tjdd
�|jD�tjd�}tj	|j|�|jj
d�}|||ddddg��tjdd
�|jD�tjd�}tj	|j|�|jjdd	�}|||dd	ddg��tjdd
�|jD�tjd�}tj	|j|�|jj
dd	�}|||ddddg��tjdd
�|jD�tjd�}tj	|j|�|jjddd�}|||ddddg��tjdd
�|jD�tjd�}tj	|j|�|jj
ddd�}|||dd	d
dg��tjdd
�|jD�tjd�}tj	|j|�tjt
dd��|jjd�}WdQRXd}tjt|d��|jjd�}WdQRXqWtdddtjg�}|jjd�}tj|td
d
dtjg��|jj
d�}tj|td	d
d tjg��dS)!NcSs(t|t�rtj||�ntj||�dS)N)r
r	rrr)r�r�rrr�_check�s
z,TestStringMethods.test_index.<locals>._checkr�r�r�r�r�r�r6r>rcSsg|]}|jd��qS)r�)r+)r^rrrrr��sz0TestStringMethods.test_index.<locals>.<listcomp>)rlr-r�cSsg|]}|jd��qS)r�)r:)r^rrrrr��scSsg|]}|jdd��qS)r�r6)r+)r^rrrrr��scSsg|]}|jdd��qS)r�r6)r:)r^rrrrr��sr��cSsg|]}|jddd��qS)r�r�r�)r+)r^rrrrr��scSsg|]}|jddd��qS)r�rr-)r:)r^rrrrr��szsubstring not found)r.ZDEz!expected a string object, not intZabcbr�ZbcberzrF)r	rrtr+rmrnrqr�rr�r:r{r|r�r�r�r)rxr�rr�r�r�r�rrr�
test_index�sJzTestStringMethods.test_indexc
Cstddtjdtjdg�}|jjddd�}tdd	tjd
tjdg�}tj||�|jjddd�}tdd
tjdtjdg�}tj||�|jjddd�}tddtjdtjdg�}tj||�tdtjddtj�ddddg	�}t|�jjddd�}tdtjd	tjtjdtjtjtjg	�}t	|t��st
�tj||�tdtjddtj�ddddg	�}t|�jjddd�}tdtjd
tjtjdtjtjtjg	�}t	|t��s�t
�tj||�tdtjddtj�ddddg	�}t|�jjddd�}tdtjdtjtjdtjtjtjg	�}t	|t��s
t
�tj||�dS)Nrrzrg�eeeeeer-r)�sidez    az    bz    crza    zb    zc    �bothz  a  z  b  z  c  T�eer>g@z   eezee   z  ee )r	rmr�rtr2rrrr�r
rw)rxrqr�r�r�r�r�rrr�test_pad�s8 $ $ $zTestStringMethods.test_padcCstddtjdtjdg�}|jjdddd�}td	d
tjdtjdg�}tj||�|jjdddd�}td
dtjdtjdg�}tj||�|jjdddd�}tddtjdtjdg�}tj||�d}tjt	|d��|jjddd�}WdQRXd}tjt	|d��|jjddd�}WdQRXdS)Nrrzrgr�r-r�X)r��fillchar�XXXXaZXXXXbZXXXXcr�aXXXXZbXXXXZcXXXXr��XXaXXZXXbXXZXXcXXz%fillchar must be a character, not str)r.�XY)r�z%fillchar must be a character, not int)
r	rmr�rtr2rrr{r|r�)rxrqr�r�r�rrr�test_pad_fillchar	s z#TestStringMethods.test_pad_fillcharr_rr-r;rGr2c
CsBtddddg�}d}tjt|d��t|j|�d�WdQRXdS)Nr��22rr�z#width must be of integer type, not*)r.r_)r	r{r|r�r�rt)rxr_r�r�rrr�test_pad_width	sz TestStringMethods.test_pad_widthcCs�dd�}xRttgD]F}|ddddg�}tjdd�}|jj|�}|d	d
ddg�}|||�qWtd
dddg�}tdddtjg�}|jj|�}tj||�dS)NcSs(t|t�rtj||�ntj||�dS)N)r
r	rrr)r�r�rrrr�&	s
z0TestStringMethods.test_translate.<locals>._checkZabcdefgZabccZcdddfgZcdefgggr*�cdeZcdedefgZcdeeZedddfgZedefgggrrzrgg333333�?r�r�)	r	rrtr�rBrmr�rr)rxr�rr�r�r�r�rrr�test_translate%	sz TestStringMethods.test_translatecCs�tddtjdtjdg�}|jjd�}tddtjdtjdg�}tj||�|jjd�}td	d
tjdtjdg�}tj||�|jjd�}tdd
tjdtjdg�}tj||�tdtjddt	j
�dddddg
�}t|�jjd�}tdtjdtjtjddtjtjtjg
�}t|t��st�tj||�t|�jjd�}td	tjd
tjtjddtjtjtjg
�}t|t��sft�tj||�t|�jjd�}tdtjd
tjtjddtjtjtjg
�}t|t��s�t�tj||�dS)Nrrzrgr�r-z  a  z  b  z  c  za    zb    zc    z    az    bz    cTZeeer>g@z eee zeee  z  eee)
r	rmr�rtrrrr-r;rr�r
rw)rxrqr�r�r�r�r�rrr�test_center_ljust_rjust9	sl 


z)TestStringMethods.test_center_ljust_rjustc.CsNtdddddg�}|jjddd�}td	d
dddg�}tj||�tjdd
�|jD�tjd�}tj	|j|�|jj
ddd�}tdddddg�}tj||�tjdd
�|jD�tjd�}tj	|j|�|jjddd�}tdddddg�}tj||�tjdd
�|jD�tjd�}tj	|j|�d}tj
t|jdd�d��|jjddd�WdQRXtj
t|jdd�d��|jj
ddd�WdQRXtj
t|jdd�d��|jjddd�WdQRXtj
t|jdd�d��|jjddd�WdQRXtj
t|jdd�d��|jj
ddd�WdQRXtj
t|jdd�d��|jjddd�WdQRXdS)Nrr�r/Zdddddr�r-r�)r�r�ZXXbbXZXcccccSsg|]}|jdd��qS)r-r�)r)r^rrrrr��	szFTestStringMethods.test_center_ljust_rjust_fillchar.<locals>.<listcomp>)rlr�ZbbXXXZccccXcSsg|]}|jdd��qS)r-r�)r-)r^rrrrr��	sr�ZXXXbbcSsg|]}|jdd��qS)r-r�)r;)r^rrrrr��	sz)fillchar must be a character, not {dtype}rt)r.r��intr>)r	rtrrrrmrnrqr�r�r-r;r{r|r��format)rxrqr�r��templaterrr� test_center_ljust_rjust_fillchar�	s:z2TestStringMethods.test_center_ljust_rjust_fillcharcCstdddddg�}|jjd�}tddd	d
dg�}tj||�tjdd�|jD�tjd
�}tj	|j|�|jjd�}tdddddg�}tj||�tjdd�|jD�tjd
�}tj	|j|�tdtj
dtj
dg�}|jjd�}tdtj
d	tj
dg�}tj||�dS)Nr�r�r�Z333Z45678r-Z00001Z00022Z00aaaZ00333cSsg|]}|jd��qS)r-)rG)r^rrrrr��	sz0TestStringMethods.test_zfill.<locals>.<listcomp>)rlr6Z001Z022cSsg|]}|jd��qS)r6)rG)r^rrrrr��	s)r	rtrGrrrmrnrqr�r�r�)rxrqr�r�rrr�
test_zfill�	szTestStringMethods.test_zfillc	Cs�tddtjdg�}|jjd�}tdddgddd	gtjd
ddgg�}tj||�td
dtjdg�}|jjd�}tj||�|jjddd�}tj||�tdtjddtj�dddg�}|jjd�}tdddgtjdd	d
gtjtjtjtjtjg�}t	|t�s�t
�tj||�|jjddd�}t	|t��s(t
�tj||�tddtjdg�}|jjd�}tdddgddd	gtjd
ddgg�}tj||�dS)Nr�r�r�r]rrzrgr�r�r_�gr��a__b__c�c__d__e�f__g__h�__F)r&�d_e_fTr>g@za,b_czc_d,ezf,g,hz[,_])r	rmr�rtr@rrrr�r
rwr)rxrqr�r�r�rrr�
test_split�	s:$
$zTestStringMethods.test_splitc	Cs�tddtjdg�}|jjd�}tdddgddd	gtjd
ddgg�}tj||�td
dtjdg�}|jjd�}tj||�|jjddd�}tj||�tdtjddtj�dddg�}|jjd�}tdddgtjdd	d
gtjtjtjtjtjg�}t	|t�s�t
�tj||�|jjddd�}t	|t��s(t
�tj||�tddtjdg�}|jjd�}tdgdgtjdgg�}tj||�tddtjdg�}|jjddd�}tddgdd	gtjddgg�}tj||�dS)Nr�r�r�r]rrzrgr�r�r_r�r�r�r�r�r�F)r&r�Tr>g@za,b_czc_d,ezf,g,hz[,_])rr��c_d�f_g)r	rmr�rtrVrrrr�r
rwr)rxrqr�r�r�rrr�test_rsplit�	sB$
zTestStringMethods.test_rsplitcCs�tdgdd�}|jjdd�}tgg�}tj||�tddddgdd�}|jjdd�}td	d
dgd	d
tjgtjtjtjgtjtjtjgg�}tj||�dS)Nr,�test)r�T)r&za b cza br4rrzrg)r	rtr@rrr�rmr�)rxrqr�r�rrr�test_split_blank_string
s

z)TestStringMethods.test_split_blank_stringcCsLtddg�}|jj�}ddg}|d|ks.t�|jj�}|d|ksHt�dS)NzWes McKinneyzTravis  OliphantZTravisZOliphantr>)r	rtr@rwrV)rxr�r�r�rrr�test_split_noargs1
s

z#TestStringMethods.test_split_noargscCs�tddg�}|jjdd�}|jj�}tj||�|jjdd�}tj||�|jjd�}|jjddd�}tj||�|jjddd�}tj||�dS)	Nzbd asdf jfgzkjasdflqw asdfnfkr>)rrZasdfr�r�)r	rtr@rr)rxr�r�r�rrr�test_split_maxsplit:
s
z%TestStringMethods.test_split_maxsplitcCsDtddg�}|jjdd�}tddgddgd��}tj||d	d
�dS)Nz
split oncezsplit once too!r>)rr@�oncez	once too!)rr>F)Zcheck_index_type)r	rtr@rr)rxr�r�r�rrr� test_split_no_pat_with_nonzero_nL
sz2TestStringMethods.test_split_no_pat_with_nonzero_ncCsXtddg�}|jjddd�}tdtddg�i�}tj||�tddg�}|jjddd�}td	d
gddgd
dgd��}tj||�tddg�}|jjddd�}td	dgddgd
dgtjdgtjdgtjdgd��}tj||�tddgddgd�}|jjddd�}td	d
gd
dgd �ddgd�}tj||�tj	t
d!d"��|jjdd#d�WdQRXdS)$N�nosplit�alsonosplitr]T)r&r�some_equal_splits�with_no_nans�some�with�equal�no�splits�nans)rr>rF�some_unequal_splits�one_of_these_things_is_not�one�unequal�of�these�things�is�not)rr>rFr6r�r-�some_splits�
with_index�preserve�me)r+r+)rr>zexpand must be)r.�
not_a_boolean)r	rtr@rrr�rmr�r{r|r�)rxr�r�r�rrr�test_split_to_dataframeR
s4z)TestStringMethods.test_split_to_dataframecCsFtddtjg�}|jjddd�}|}tj||�|jdks>t�tddtjdg�}|jjddd�}t	j
ddtjtjtjgdddgg�}tj||�|jdks�t�tddtjdg�}|jjddd�}t	j
d	ddtjtjtjfdtjtjtjtjtjtjfd g�}tj||�|jdk�st�tjt
dd��|jjddd�WdQRXdS)!Nr�r�r]T)r&r>r�r�r�r�r�r�r�r�r6r�r�r�r�r�r�r�r�r�r.zexpand must be)r.r)r�r�r�)r�r�r�)r�r�r�r�r�r�)NNNNNN)rrmr�rtr@rr�nlevelsrwrrvr{r|r�)rxrWr�r�rrr�test_split_to_multiindex_expandw
s2z1TestStringMethods.test_split_to_multiindex_expandcCs@tddg�}|jjddd�}tdtddg�i�}tj||�tddg�}|jjddd�}td	d
gddgd
dgd��}tj||�|jjdddd�}td	d
gddgd
dgd��}tj||�|jjdddd�}tddgd
dgd��}tj||�tddgddgd�}|jjddd�}td	d
gd
dgd�ddgd�}tj||�dS)Nr�r�r]T)r&rr�r�r�r�r�r�r�r�)rr>rFrF)r&rr>�
some_equal�with_no)rr>r�rrr)r+r+)r	rtrVrrr�)rxr�r�r�rrr�test_rsplit_to_dataframe_expand�
s*z1TestStringMethods.test_rsplit_to_dataframe_expandcCs�tddg�}|jjddd�}|}tj||�|jdks:t�tddg�}|jjddd�}tjddg�}tj||�|jdks~t�tddg�}|jjdddd�}tjddg�}tj||�|jdks�t�dS)Nr�r�r]T)r&r>r�r�r�r�r�r�r�r�r6)r&rrrrF)r�r�r�)r�r�r�)rr�)rr�)	rrtrVrrrrwrrv)rxrWr�r�rrr� test_rsplit_to_multiindex_expand�
s 
z2TestStringMethods.test_rsplit_to_multiindex_expandcCshtdtjg�}|jjddd�}tdddgtjtjtjgg�}tj||�tdd	�|j	d
D��sdt
�dS)Nzfoo,bar,bazrT)r&r�r	�bazcss|]}tj|�VqdS)N)rm�isnan)r^r�rrrr��
sz:TestStringMethods.test_split_nan_expand.<locals>.<genexpr>r>)r	rmr�rtr@rrr��all�ilocrw)rxr�r�r�rrr�test_split_nan_expand�
s
z'TestStringMethods.test_split_nan_expandcCs�tddgdd�}|jjd�}tddgdd	ggdd�}tj||�|jjdd
d�}tddgdd	gg�}tj||�tddgdd�}|jjd�}tddgdd	ggdd�}|jdks�t	�tj
||�|jjdd
d�}tjddg�}|jd
ks�t	�tj
||�dS)Nza,bzc,dr�)r�rrrzrgr�T)r&r>rF)rrz)rgr�)
r	rtr@rrrr�rrrwrrrv)rxr�r5r�rWrrr�test_split_with_name�
s z&TestStringMethods.test_split_with_namecCs�tddtjddg�}|jjddd�}td1d2tjd3dg�}tj||�|jjddd�}td4d5tjd6dg�}tj||�tddtjddg�}|jjddd�}td7d8tjd9dg�}tj||�|jjddd�}td:d;tjd<dg�}tj||�tddtjddg�}|jjdd�}td=d>tjd?dg�}tj||�|jjdd�}td@dAtjdBdg�}tj||�td&d'tjd(dg�}|jjddd�}tdCdDtjdEdg�}tj||�|jjddd�}tdFdGtjdHdg�}tj||�tddtjdg�}|jjddd�}tdIdJtjdKg�}tj||�|jjddd�}tdLdMtjdNg�}tj||�td*d+d,d-g�}|jjddd�j�}|d.d/�|D�k�svt	�|jjddd�j�}|d0d/�|D�k�s�t	�dS)ONr�r�r�r]F)r&r�b_crg�d_er_�g_hr�r�r�r�r�r�r�r�r��b__c�d__e�g__h�a__b�c__d�f__gza b czc d ezf g hr4�b c�d e�g h�a b�c d�f gr*r��fghr,ZA_B_CZB_C_DZE_F_Gr�cSsg|]}|jd��qS)r])r3)r^rrrrr�Esz;TestStringMethods.test_partition_series.<locals>.<listcomp>cSsg|]}|jd��qS)r])r<)r^rrrrr�Gs)rr]r)rgr]r)r_r]r)r�r]rg)r�r]r�)r�r]r�)rr�r)rgr�r)r_r�r)rr�rg)rr�r�)rr�r�)rr4r)rgr4r)r_r4r)rr4rg)rr4r�)rr4r�)r*r,r,)r�r,r,)r r,r,)r,r,r*)r,r,r�)r,r,r )rr]r)rgr]r)r_r]r)r�r]rg)r�r]r�)r�r]r�)
r	rmr�rtr3rrr<rrw)rxrqr�r�rrr�test_partition_series�
slz'TestStringMethods.test_partition_seriescCsTtdddtjdg�}|jjddd�}ttjdddtjdgtd
��}tj||�|j	dks\t
�|jjddd�}ttjdddtjdgtd
��}tj||�|j	dks�t
�|jjd�}tdddtjtjtjfdg�}tj||�t|t
��s�t
�|j	dk�s�t
�|jjd�}tdd d!tjtjtjfd"g�}tj||�t|t
��s@t
�|j	dk�sPt
�dS)#Nr�r�r�r]F)r&rrrgrr_r)rlr>r�r�r�r�r�r6)rr]r)rgr]r)r_r]r)r�r]rg)r�r]r�)r�r]r�)rr]r)rgr]r)r_r]r)NNN)r�r]rg)r�r]r�)r�r]r�)NNN)rrmr�rtr3rnrorrrrwr<r
r)rxrqr�r�rrr�test_partition_indexIsF

z&TestStringMethods.test_partition_indexcCsdtddtjddg�}|jjd�}tddtjddgddtjddgdd	tjd
dgd��}tj||�|jjd�}tdd
tjddgddtjddgddtjddgd��}tj||�tddtjddg�}|jjddd�}tddtjddgddtjddgdd	tjd
dgd��}tj||�|jjddd�}tdd
tjddgddtjddgddtjddgd��}tj||�dS)Nr�r�r�r]rrgr_rrr)rr>rFr�r�r�r�r�T)r&)	r	rmr�rtr3rrr�r<)rxrqr�r�rrr�test_partition_to_dataframe~s4z-TestStringMethods.test_partition_to_dataframecCs�tddgdd�}|jjd�}tddgddgdd	gd
��}tj||�|jjddd�}tddgdd�}tj||�tddgdd�}|jjd�}tj	ddg�}|j
d
ks�t�tj||�|jjddd�}tt
jddg�dd�}|j
dk�s�t�tj||�dS)Nza,bzc,dr�)r�rrrgrzr�)rr>rFF)r&r6r>)rrrz)rgrr�)rrrz)rgrr�)rrrz)rgrr�)r	rtr3rrr�rrrrvrrwrrmrn)rxr�r5r�rWrrr�test_partition_with_name�s z*TestStringMethods.test_partition_with_namecCsbtddtjdg�}|jjdd�}|jjd�}tj||�|jjdd�}|jjd�}tj||�dS)Nr�r�r�r])r)r	rmr�rtr3rr�r<)rxrqr�r�rrr�test_partition_sep_kwarg�sz*TestStringMethods.test_partition_sep_kwargcCsZtdg�}|jjd�}tdddgg�}tj||�|jjdd�}tdg�}tj||�dS)NzA|B|Cr�r�r�r�r4zA B C)r	rtr@rrr7)rxr�r�r�rrr�test_pipe_failures�s

z$TestStringMethods.test_pipe_failureszstart, stop, step, expectedr-r�r	rrZowtoofaaZowtrabaaZxuqzabaarZotoZatoZaqxZofa�abac
	Cs�tddtjdg�}|jj|||�}tj||�tdtjddtj�dddg�}t|�jjdd�}td	tjd
tjtjtjtjtjg�}	t	|t�s�t
�tj||	�t|�jjddd
�}tdtjdtjtjtjtjtjg�}	dS)NZaafootwoZaabartwoZaabazquxTr>g@rFr-r�r	ZoofZrabr�)r	rmr�rtr=rrrr�r
rwr)
rx�startr�r�r�rqr�r�r�r�rrr�
test_slice�s$zTestStringMethods.test_slicecCs�tddddtjg�}tddddtjg�}|jjdd	�}tj||�td
ddd
tjg�}|jjdd	d
�}tj||�tdddd
tjg�}|jjddd
�}tj||�tdddd
tjg�}|jjddd
�}tj||�tdddd
tjg�}|jjddd
�}tj||�tdddd
tjg�}|jjdd d
�}tj||�tdddd
tjg�}|jjddd
�}tj||�tdddd
tjg�}|jjd!d	d
�}tj||�dS)"N�shortza bit longerZevenlongerthanthatr,Zshrtza it longerZevnlongerthanthatrFr6Zshzrtza zit longerZevznlongerthanthatr8Zshzortz
a zbit longerZevzenlongerthanthatr>Zshorzza bit longezZevenlongerthanthazZzrtZzerZzatZshortzza bit zngerZevenlozerthanthatr.r�Zevenlongzerthanthatrr����i����)r	rmr�rtr?rr)rxrqr�r�rrr�test_slice_replace�s2z$TestStringMethods.test_slice_replacecCs�tddtjdg�}|jj�}tddtjdg�}tj||�|jj�}tddtjdg�}tj||�|jj�}td	d
tjdg�}tj||�dS)Nz  aa   z bb 
zcc  r�r��cczaa   zbb 
z  aaz bb)	r	rmr�rtrXrrrUrW)rxrqr�r�rrr�test_strip_lstrip_rstrips


z*TestStringMethods.test_strip_lstrip_rstripc	Cstdtjddtj�dddg�}t|�jj�}tdtjdtjtjtjtjtjg�}t|t�s^t�t	j
||�t|�jj�}tdtjd	tjtjtjtjtjg�}t|t�s�t�t	j
||�t|�jj�}td
tjdtjtjtjtjtjg�}t|t�s�t�t	j
||�dS)Nz  aa  z bb 	
Tr>g@r�r�zaa  zbb 	
z  aaz bb)
r	rmr�rr�rtrXr
rwrrrUrW)rxr�r�r�rrr�test_strip_lstrip_rstrip_mixed-s$$$z0TestStringMethods.test_strip_lstrip_rstrip_mixedcCs�tdddg�}|jjd�}tdddg�}tj||�|jjd�}tdddg�}tj||�|jjd�}td	ddg�}tj||�dS)
NZxxABCxxzxx BNSDzLDFJH xxr��ABCz BNSDzLDFJH ZABCxxZxxABC)r	rtrXrrrUrW)rxrqr�r�rrr�test_strip_lstrip_rstrip_argsEsz/TestStringMethods.test_strip_lstrip_rstrip_argsc
Cs�tddddddddd	g	�}tddd
ddddd
dg	�}|jjddd�}tj||�tdtjdg�}tdtjdg�}|jjd�}tj||�dS)Nzhello worldzhello world!z
hello world!!ZabcdefabcdeZabcdefabcdefZ
abcdefabcdefazab ab ab ab z
ab ab ab ab a�	z
hello
world!!zabcdefabcdef
azab ab ab abz
ab ab ab ab
ar,�T)�break_long_wordsz  pre  u¬€耀 abadcafez  preu¬€耀 ab
adcafer.)r	rtrErrrmr�)rxrqr�r�rrr�	test_wrapTs4zTestStringMethods.test_wrapc	Cs*tddtjdg�}|jjd�jjd�}tddtjdg�}tj||�tdtjdd	tj	�ddd
g�}t|�jjd�jjd�}tdtjdtjtjtjtjtjg�}t
|t�s�t�tj||�tddd
g�}|jjd�jjd�}tddtjg�}tj||�|jjd�jjd�}tddtjg�}tj||�dS)Nr�r�r�r]r>rzr�r�Tg@Z	1_2_3_4_5Z
6_7_8_9_10Z11_12rFr��8r6���)
r	rmr�rtr@r*rrrr�r
rwr)rxrqr�r�r�r�r�rrr�test_get�s $zTestStringMethods.test_getcCs~tddddgdddhdddd�g�}|jjd�}tddtjdg�}tj||�|jjd	�}tddtjtjg�}tj||�dS)
Nr>rFr6rrzrg)r>rFr6)r>rFr6r�)r	rtr*rmr�rr)rxrqr�r�rrr�test_get_complex�s$z"TestStringMethods.test_get_complex�to_typecCsjt||ddg�g�g�}|jjd�}t|ddg�g�}tj||�|jjd�}ttjg�}tj||�dS)Nr>rFr)r	rtr*rrrmr�)rxr:rqr�r�rrr�test_get_complex_nested�sz)TestStringMethods.test_get_complex_nestedcCs8tddddddtjddd	g
�}|jjd
�}tddddddtjdddg
�}tj||�|jjd
dd
�}tddddddtjdddg
�}tj||�|jjd�}tddddddtjdddg
�}tj||�|jjd�}tddddddtjdddg
�}tj||�|jjddd
�}tddddddtjdddg
�}tj||�dS)Nr�r�r��Aaba�Bacar,�CABA�dogrrFT)r�ZAar))r	rmr�rtrrr)rxr�r�r�rrr�test_contains_moar�s*z$TestStringMethods.test_contains_moarcCs�ttjtjtjgtjd�}|jjddd�}tdddgtjd�}tj||�|jjddd�}tdddgtjd�}tj||�|jjddd�}tdddgtjd�}tj||�|jjd�}ttjtjtjgtjd�}tj||�dS)N)rlr�F)r#T)	r	rmr�r�rtrr�rr)rxr�r�r�rrr�test_contains_nan�sz#TestStringMethods.test_contains_nancCs�tddddddtjddd	g
�}|jjdd
�}td
dddddtjddd	g
�}tj||�|jjdd
d
d�}td
dddddtjdddg
�}tj||�|jjddd
d�}tddddddtjdddg
�}tj||�dS)Nr�r�r�r<r=r,r>r?r�YYYZYYYaba�CYYYBYYYF)r��
YYYYYYbYYY�BYYYcYYY�cYYYtz^.a|dogzXX-XX zXX-XX bazXX-XX cazXX-XX BAzXX-XX t)r	rmr�rtr7rr)rxr�r�r�rrr�test_replace_moar�s>z#TestStringMethods.test_replace_moarc
Cs�tdddddtjdddg	�}|jd	}|jjd	�}tj||�|jdd
�}|jjd
d�}tj||�|jddd�}|jjddd�}tj||�dS)NrBr�r�rDrErCr?rFrr6)r�rFr>)r(r�r�r�)r	rmr�rtr*rrr=)rxr�r�r�rrr�test_string_slice_get_syntax
s&
z.TestStringMethods.test_string_slice_get_syntaxcCsltddd
g�}|jd}tdtjdg�}tj||�tdddg�}|jd}td	tjd
g�}tj||�dS)Nr>rFr6r�r-r�rzr)r�r)r>rF)r>)r6r�r-)r	rtrmr�rr)rxr�r�r�rrr�test_string_slice_out_of_bounds2
s

z1TestStringMethods.test_string_slice_out_of_boundscCs
dddtjd�}t|�}d}|jj|tjdd�}|jdj�d	d
dgksLt	�|jj
|tjd�}|dsjt	�|jj|tjd�}|ds�t	�|jj|tjd�}|dddks�t	�|jj
|tjd�}|dd
ks�t	�tjt��|jj|tjd�}WdQRX|d�st	�dS)Nzdave@google.comzsteve@gmail.comz
rob@gmail.com)rlZSteveZRobZWesz,([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\.([A-Z]{2,4})T)rr&rrar�rb)rr>)rar�rb)rmr�r	rtr$rr'rrrwr.r/r)rrr��UserWarningr)rxr�r�r�rrr�test_match_findall_flags?
s&
z*TestStringMethods.test_match_findall_flagscCsHtdddg�}|jjd�}dd�}|jjd�}|j|�}tj||�dS)Nrrzuaäzutf-8cSs
|jd�S)Nzutf-8)r)r�rrrr�a
sz6TestStringMethods.test_encode_decode.<locals>.<lambda>)r	rtr!rr�rr)rx�baseZseriesr_r�r�rrr�test_encode_decode]
s
z$TestStringMethods.test_encode_decodecCs�tdddg�}d}tjt|d��|jjd�WdQRXdd�}|jjdd	�}|j|�}tj||�td
ddg�}d
}tjt	|d��|jj
d�WdQRXdd�}|jj
dd	�}|j|�}tj||�dS)Nrrzuaz['charmap' codec can't encode character '\\x9d' in position 1: character maps to <undefined>)r.�cp1252cSs|jdd�S)NrN�ignore)r!)r�rrrr�q
sz=TestStringMethods.test_encode_decode_errors.<locals>.<lambda>rOri�bsa�zS'charmap' codec can't decode byte 0x9d in position 1: character maps to <undefined>cSs|jdd�S)NrNrO)r)r�rrrr�
s)r	r{r|�UnicodeEncodeErrorrtr!r�rr�UnicodeDecodeErrorr)rxZ
encodeBaser�r_r�r�Z
decodeBaserrr�test_encode_decode_errorsg
s 

z+TestStringMethods.test_encode_decode_errorscCs�dddtjdg}t|ddddd	gd
�}dddtjdg}t|ddddd	gd
�}|jjd
�}tj||�tdddtjdgddddd	gd
�}|jjd�}tj||�tjt	dd��|jjd�WdQRXt
dddg�}t
dddg�}|jjd
�}tj||�dS)Nr0u	ABCu	123u	アイエrrzrgr�r�)r+Z123u	アイエ�NFKCr1zinvalid normalization form)r.r�)rmr�r	rtr0rrr{r|r�rr)rxrqr�Znormedr�r�rrr�test_normalize�
s  z TestStringMethods.test_normalizecCs�ddlm}ddgdfdddgdfdddgd	fddddgdfd
tddd�gd	fg}xJ|D]B\}}t|�}tt|�j|�s|t�t|j|�s�t�|j|ksXt�qXWxJ|D]B\}}t|�}tt|�j|�s�t�t|j|�s�t�|j|ks�t�q�Wdt	j
gdftddd�gd
ftd�gdfg}xr|D]j\}}t|�}d}tj
t|d��t|�jWdQRXtj
t|d��|jWdQRX|j|k�st��qWtjddg�}|jd	k�s�t�d}tj
t|d��|jWdQRXdS)Nr)rvrrzrfr>z
mixed-integerg�������?r�r�i�ZfloatingZ
datetime64Ztimedelta64z-Can only use .str accessor with string values)r.z5Can only use .str accessor with Index, not MultiIndex)rrz)rrz)�pandas.core.stringsrvrrr
r	rtrwZ
inferred_typermr�rr{r|r}rrv)rxrvZcasesrq�tprWr�rrr�"test_index_str_accessor_visibility�
s@
z4TestStringMethods.test_index_str_accessor_visibilityc	Cs2ttd��}tjtdd��d|j_WdQRXdS)NZaabbcdez You cannot add any new attribute)r.r)r	r�r{r|r}rtZxlabel)rxr�rrr�#test_str_accessor_no_new_attributes�
sz5TestStringMethods.test_str_accessor_no_new_attributesc	Cs^ttjtd�d�jt��}ttjtd�d�jt��}tjtdd��|j	j
|�WdQRXdS)Nr*ZS1�defz$Cannot use .str.cat with values of.*)r.)r	rmrnr�r�ror{r|r�rtr)rx�lhs�rhsrrr�test_method_on_bytes�
sz&TestStringMethods.test_method_on_bytescCs>tdtjddg�}tdtjddg�}|jj�}tj||�dS)N�ssr�Zssd�ßußd)r	rmr�rtr\rr)rxr�r�r�rrr�
test_casefold�
s
zTestStringMethods.test_casefold)N)r~)Nr)r~r)N)r~r)Nr)r~rr�r�r�)��__name__�
__module__�__qualname__ryr�r{r��parametrizeror�r�r�r�r�r�r�r	rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rmr��pdr�rrrr
rrrr r%r(r+r0r1r6r8r9r:r[r\r^r_r`rzr|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�rrr	r
rrr!r"r#r$r%r&r)r,r.r/r1r5r8r9r�rnr;r@rArGrHrIrKrMrSrUrXrYr]r`rrrrrs�sB
(
%e+D##	$$5'-/04	f' F*&((6. 	J,+0	%&U5-(#
,$",

+rsc
Cs�|\}}}|dkrtjd�ddtjdg}t|td�}t|dd�}t|j|�||�}t|j|�||�}t|t��r4|j	dkr�t
j|j�j
�r�|j	dks�t�|jt�}n�|j	dkr�t
j|j
d	d
�r�|j	dks�t�|jt�}nX|j	dkr�|j	dks�t�|jd�}n4|j	d
k�rx|j�j��rx|j	dk�s(t�|jd
�}nDt|t��rx|jdd�j}	t||	jdk��sft�||	jt�||	<tj||�dS)Nrzdecode requires bytes.rr�r,)rlrfroT)Zskipnar7r��float�Int64)�include)r{�skiprmr�r	ror�rtr
rlrZis_string_arrayr�rqrwr�Z
is_bool_arrayr�anyrZ
select_dtypesrGr
�dtypesr�assert_equal)
rer�r�r�r�rrzr�r�rGrrr�test_string_array�
s8


rmzmethod,expectedcCs<tddgdd�}t|j|�d�}t|dd�}tj||�dS)Nr'rf)rlrrg)r	r�rtrr)r�r�r�r�rrr�'test_string_array_numeric_integer_arrays
rncCs<tdddgdd�}t|j|��}t|dd�}tj||�dS)Nrr�rf)rlr7)r	r�rtrr)r�r�r�r�rrr�test_string_array_boolean_arrays
rocCsttdddgdd�}tdddgdd�}d}|jj|dd	�}|jj|dd	�}t|jdk�sZt�|jt�}tj	||�dS)
NZa1Zb2r-rf)rlroz(\w)(\d)F)r&)
r	rtr$r
rkrwr�rorrl)rrzr�r�r�rrr�test_string_array_extract&s
rprcCsFtjdddg�}|jj|dddg��}tjddd	g�}tj||�dS)
Nrrzrgr�r$r8ZaxZby�cz)rer	rtrrr)rr�r�r�rrr�test_cat_different_classes5srr)r)r)r)r )r )r)r)r)r%)r%)r%)r)r)r)r,)r)r)r)r)r1)r)r4)r4)r6)rr8)r)r,)r)r4)r4)rr>)rr>r8)r4)r4)r)r)r)rF)r)3rrrZnumpyrmZnumpy.randomrr{Zpandas._libsrZpandasrerrrr	r
rrZpandas._testingZ_testingrrV�corerurr��zipZ_any_string_methodrbr]�dirrvr�Zmissing_methodsrwZfixturerer�Z"_any_allowed_skipna_inferred_dtyperrrsrmr�rdrnrorpr�rnrrrrrr�<module>s$


 '5(