(VfiddlmZddlZddlmZmZmZmZddlZ ddl m Z ddl m Z ddlmZddlmcmZddlmZddlmZmZmZmZmZmZdd lmZmZm Z m!Z!dd l"m#Z#ddl$Z%dd l$m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0dd l1m2Z2m3Z3m4Z4m5Z5m6Z6dd l7m8Z8ddl9m:Z:ddl;mZ>erddl?m@Z@ didjdZAdkdZBdldmd!ZC dndod-ZD dpdqd/ZEdrdsd2ZFdkd3ZGdkd4ZH dtdud7ZI dvdwd9ZJdxdyd;ZK dzd{d>ZL d|d{d@ZM d}d~dBZN dddFZOdde jPe jPe jPdGfddJZQdddde jPdCdddde jPe jPdKf ddCdLddSZRddddddCe jPdCddCdde jPe jPdTfddXZSdkdYZTdkdZZUdkd[ZVdkd\ZWdd`ZXddeZY dddhZZdS)) annotationsN) TYPE_CHECKINGLiteralNoReturncast)lib)is_matching_na) SparseIndex)compare_mismatched_resolutions)is_boolis_float_dtypeis_integer_dtype is_numberis_numeric_dtypeneeds_i8_conversion)CategoricalDtypeDatetimeTZDtypeExtensionDtype NumpyEADtype)array_equivalent) Categorical DataFrame DatetimeIndexIndex IntervalDtype IntervalIndex MultiIndex PeriodIndex RangeIndexSeriesTimedeltaIndex) DatetimeArrayExtensionArray IntervalArray PeriodArrayTimedeltaArray)DatetimeLikeArrayMixin) StringDtype)safe_sort_index) pprint_thing)DtypeObjequivh㈵>:0yE> check_dtypebool | Literal['equiv']rtolfloatatolreturnNonec `t|trt||fd|||d|dSt|trt ||fd|||d|dSt|t rt ||fd|||d|dS|rt|rt|rnjt|rt|rnKt|tj st|tj rd}nd}t|||tj ||ft|||d|dS) a Check that the left and right objects are approximately equal. By approximately equal, we refer to objects that are numbers or that contain numbers which may be equivalent to specific levels of precision. Parameters ---------- left : object right : object check_dtype : bool or {'equiv'}, default 'equiv' Check dtype if both a and b are the same type. If 'equiv' is passed in, then `RangeIndex` and `Index` with int64 dtype are also considered equivalent when doing type checking. rtol : float, default 1e-5 Relative tolerance. atol : float, default 1e-8 Absolute tolerance. F) check_exactexactr1r3)r7r/r1r3 numpy arrayInputobj)r/r1r3N) isinstancerassert_index_equalr assert_series_equalrassert_frame_equalrr npndarrayassert_class_equal_testingassert_almost_equalbool)leftrightr/r1r3kwargsr<s Hc:\PYTHON\DbComparer\venv\Lib\site-packages\pandas/_testing/asserters.pyrErEBs6$4             D& ! !)    #         D) $ $    #          9 99U#3#3 9 975>> 9dBJ//":eRZ3P3P"'CC!C"4C8888 $ % %)+%6%6T  PV     c |j}t||s%t|d|dt|dt||s%t|d|dt|ddS)a Helper method for our assert_* methods that ensures that the two objects being compared have the right type before proceeding with the comparison. Parameters ---------- left : The first object being compared. right : The second object being compared. cls : The class type to check against. Raises ------ AssertionError : Either `left` or `right` is not an instance of `cls`. z Expected type z, found z insteadN)__name__r=AssertionErrortype)rGrHclscls_names rJ_check_isinstancerRs |H dC   I I I IT$ZZ I I I    eS ! !  J J J JT%[[ J J J     rKT compare_keysrFc`t||ttj|||dS)N)rS)rRdictrDassert_dict_equal)rGrHrSs rJrVrVs2dE4((( tUFFFFFFrKrrGrHr8 bool | str check_namesr7check_categorical check_orderr<strc d} ddfd } t||t| ||| |j|jkr/| d } |jd |} |jd |}t| | | |t |t |kr?| d } t |d |} t |d |}t| | | ||st |}t |}t |trtt|}t|jD]}d |d } t|j ||j |||||| t|j ||j |nR#t$rE||}||}t||||||| YnwxYw| |j ||j || Րn|rщr||s|j|jk}t |t$js#td|d}t%j|t.dzt |z }| dt%j|dd}t| |||n5t3}t5j|j|j|||| |||rt;d||| t |t<st |t<rt;d||| t |t>st |t>rtA|j|jrUt |j!tDst |j!tDr#tG|j|j| ddSdSdS)ak Check that left and right Index are equal. Parameters ---------- left : Index right : Index exact : bool or {'equiv'}, default 'equiv' Whether to check the Index class, dtype and inferred_type are identical. If 'equiv', then RangeIndex can be substituted for Index with an int64 dtype as well. check_names : bool, default True Whether to check the names attribute. check_exact : bool, default True Whether to compare number exactly. check_categorical : bool, default True Whether to compare internal Categorical exactly. check_order : bool, default True Whether to compare the order of index entries as well as their values. If True, both indexes must contain the same elements, in the same order. If False, both indexes must contain the same elements, but in any order. rtol : float, default 1e-5 Relative tolerance. Only used when check_exact is False. atol : float, default 1e-8 Absolute tolerance. Only used when check_exact is False. obj : str, default 'Index' Specify object name being compared, internally used to show appropriate assertion message. Examples -------- >>> from pandas import testing as tm >>> a = pd.Index([1, 2, 3]) >>> b = pd.Index([1, 2, 3]) >>> tm.assert_index_equal(a, b) Trr<r[r4r5cPsdSt|||td|||t|jtrMt|jtr3r/td|||t |j|jdStd|||dS)N)r8r< inferred_typer;dtype)r8)rCassert_attr_equalr=r_rr> categories)rGrHr<rYr8s rJ _check_typesz(assert_index_equal.._check_typess  F4e====/4C@@@@ dj"2 3 3  K)9 9  ! S!'4C@@@@"4?E4DERRRR F'4C888888rKr;z levels are different, z length are differentzMultiIndex level [])r8rXr7rYr1r3r<r#Y@ values are different ( %))r1r3r/r<lobjrobjnamesr_ categoryN)rr<r[r4r5)$rRrnlevelsraise_assert_detaillenr)r=rrranger>levelsassert_numpy_array_equalcodesrNget_level_valuesequals_valuesrArBfillnasumastypeintroundrFrDrEvaluesr`rrassert_interval_array_equalr_rassert_categorical_equal)rGrHr8rXr7rYrZr1r3r<__tracebackhide__rbmsg1msg2msg3levelrillevelrlevelmismatchdiffmsg exact_bools ` ` rJr>r>s`99999999&dE5)))Lu#&&&& |u}$$,,,,(($((-**5**CtT222 4yyCJJ,,,d))%%t%%e**''''CtT222 't$$&&$ ##< Z''4<(( K KE0000D "K&L' + +&7    )E):EK.repr_classhs( a   HAwwrKidxrr4rFcXt|tupt|tS)zClasses that are a RangeIndex (sub-)instance or exactly an `Index` . This only checks class equivalence. There is a separate check that the dtype is int64. )rOrr=r)rs rJis_class_equivz*assert_class_equal..is_class_equivos$ CyyE!@ZZ%@%@@rKNr,z classes are different)rrr4rF)rOro)rGrHr8r<rrrrs rJrCrC`s    AAAA DzzT%[[    >$   NN5$9$9  F  ( ( (CS**T"2"2JJu4E4EFFFFFrK Attributesattrcpd}t||}t||}||ust||rdS ||k}n#t$rd}YnwxYw|tju|tjuz rd}n)t |t s|}|sd|d}t||||dS)aO Check attributes are equal. Both objects must have attribute. Parameters ---------- attr : str Attribute name being compared. left : object right : object obj : str, default 'Attributes' Specify object name being compared, internally used to show appropriate assertion message TNFz Attribute "z" are different) getattrr TypeErrorpdNAr=rFallro) rrGrHr<r left_attr right_attrresultrs rJr`r`sd##I%%JJ.J"G"Gtj(  RUzRU23  % % =1D111Ci<<< 4sA AAcddlm}ddlm}t |t t jfrzt |t r|j}| D]G}dtt|j }t ||tfs J|HdSdtt|j }t ||ttfs J|dS)Nr)Artist)AxeszBone of 'objs' is not a matplotlib Axes instance, type encountered zoobjs is neither an ndarray of Artist instances nor a single ArtistArtist instance, tuple, or dict, 'objs' is a )matplotlib.artistrmatplotlib.axesrr=r rArBrwravelreprrOrMrUtuple)objsrrelrs rJ"assert_is_valid_plot_return_objectrs(((((($$$$$$$,--< dF # # $(b):$;$;>> b4,// 4 4 4 4/ 4  5 5 +DJJ'(( + + $ 566;;;;6;;rKc<t|ttfr|j}t|tjr6t |t jt j|dSt||| dS)z#Assert that the sequence is sorted.N) r=rr r}rArBrssortarrayassert_extension_array_equalargsort)seqs rJassert_is_sortedrs~#v''j#rz""> bgbhsmm&<&<=====$S#ckkmm*<=====rKrcheck_category_orderct||tt|jtst|jtrd}nd}|rAt |j|j|d|t |j|j||dn |j}|j}n#t$r|j|j}}YnwxYwt |||d|t |j |j|j |j|d|td||| d S) a} Test that Categoricals are equivalent. Parameters ---------- left : Categorical right : Categorical check_dtype : bool, default True Check that integer dtype of the codes are the same. check_category_order : bool, default True Whether the order of the categories should be compared, which implies identical integer codes. If False, only the resulting values are compared. The ordered attribute is checked regardless. obj : str, default 'Categorical' Specify object name being compared, internally used to show appropriate assertion message. r,Tz .categories)r<r8z.codesr/r<z.valuesorderedr;N) rRrr=rarr>rsrt sort_valuesrtaker`)rGrHr/rr<r8lcrcs rJrrs2dE;///$/:..* *33  OU-c3F3F3Fe     ! J S...      7,,..B!--//BB 7 7 7_e&6BBB 7 2r#':':':%HHHH O  , ,   ! !%+ . .     iu#666666s2CC"!C"r$ct||ti}|jjjdvrd|d<t |j|jfd|di|t |j|jfd|di|td|||dS) a Test that two IntervalArrays are equivalent. Parameters ---------- left, right : IntervalArray The IntervalArrays to compare. exact : bool or {'equiv'}, default 'equiv' Whether to check the Index class, dtype and inferred_type are identical. If 'equiv', then RangeIndex can be substituted for Index with an int64 dtype as well. obj : str, default 'IntervalArray' Specify object name being compared, internally used to show appropriate assertion message mMF check_freqr<z.leftclosedr;N)rRr$_leftr_kind assert_equal_rightr`)rGrHr8r<rIs rJr~r~s$dE=111 F z$$$|U[FFmmmFvFFFelHH3 HHHHhe555555rKr%ct||tt|j|j|dt d|||dS)N ._ndarrayr;r_)rRr%rs_ndarrayr`)rGrHr<s rJassert_period_array_equalr&sSdE;///T]EN3@Q@Q@QRRRRgtU444444rKr"rcd}t||tt|j|j|d|rt d|||t d|||dS)NTrr;freqtz)rRr"rsrr`rGrHr<rrs rJassert_datetime_array_equalr-szdE=111T]EN3@Q@Q@QRRRR8&$37777dD%S111111rKr&cd}t||tt|j|j|d|rt d|||dSdS)NTrr;r)rRr&rsrr`rs rJassert_timedelta_array_equalr9smdE>222T]EN3@Q@Q@QRRRR8&$377777788rKrcd}|d|}t|trtj|}t|tjr|dt |z }t|tjrt |}nTt|t tfrt|}n(t|trd|j d|j d}t|tjrt |}nTt|t tfrt|}n(t|trd|j d|j d}|d|d|z }||d |z }||d |z }t|) NTz are different z [index]: zStringDtype(storage=z , na_value=)z [left]: z [right]: z [diff]:  ) r=rrAasarrayrBr*rrrr(storagena_valuerN) r<messagerGrHr first_diff index_valuesrrs rJroroCs    C,&&0z,// , ++: 9\,77999$ ##PD!! D+\: ; ;PDzz D+ & &PPdlOOt}OOO%$$SU## E,l; < <SU  E; ' 'SRu}RRRRR       C  "D"""  J      rKFr9 strict_nancjd}t||t||tjd} | |} | |} |dkr3| | ur.t t | dt | n8|dkr2| | ur.t t | dt | dfd } t || s | ||||rIt|tjr1t|tjrtd ||d Sd Sd Sd S)a3 Check that 'np.ndarray' is equivalent. Parameters ---------- left, right : numpy.ndarray or iterable The two arrays to be compared. strict_nan : bool, default False If True, consider NaN and None to be different. check_dtype : bool, default True Check dtype if both a and b are np.ndarray. err_msg : str, default None If provided, used as assertion message. check_same : None|'copy'|'same', default None Ensure left and right refer/do not refer to the same memory area. obj : str, default 'numpy array' Specify object name being compared, internally used to show appropriate assertion message. index_values : Index | numpy.ndarray, default None optional index (shared by both left and right), used in output. Tr;c6t|dd|jn|S)Nbase)rrr;s rJ _get_basez+assert_numpy_array_equal.._get_bases"355AsxxsJrKsamez is not copyz is r4rcZ||j|jkrtd|j|jd}t||D]\}}t|| s|dz }|dz|jz }dt j|dd}t||| t|) Nz shapes are differentrrrerfrgrh)r)shaperoziprsizerAr|rN) rGrHerr_msgrleft_arr right_arrrrr<rs rJ_raisez(assert_numpy_array_equal.._raises ?zU[((#C666 EKD'*4'7'7  #)') SSSAID%<$)+DGG$1B1BGGGC S$L Q Q Q QW%%%rKrr_Nr4r) rCrRrArBrNrrr=r`) rGrHrr/r check_samer<rrr left_base right_basers ` `` rJrsrsos>tU,,,,dE2:...KKK $I5!!JV J & & DOO!O!OT*=M=M!O!OPP P ' v    " " DOO!K!Kj9I9I!K!KLL L&&&&&&&&( D%J ? ? ?%tUG$$$= dBJ ' ' =Jubj,I,I = gtU < < < < < <== = = = =rKr#bool | lib.NoDefaultfloat | lib.NoDefaultc |tjuro|tjura|tjurSt|jrt |j p(t|jot |j }n|tjurd}|tjur|nd}|tjur|nd}t |t s Jdt |t s Jd|rtd||d|t |trt |trpt|t|krO|s |jj d vrt |jtjs tt|jj}ntj|jd }t |jtjs tt|jj} ntj|jd } || kr9t!|j|jt$jrd St+tj|jtj|j|| d Stj|} tj|} t+| | |d |t |jt2r[|jjdkrK|jjtjur3tjd|j| Ds Jdt |jt2r[|jjdkrK|jjtjur3tjd|j| Ds Jd|| t<} || t<} |rt+| | ||d St?j | | tC|||||d S)a Check that left and right ExtensionArrays are equal. Parameters ---------- left, right : ExtensionArray The two arrays to compare. check_dtype : bool, default True Whether to check if the ExtensionArray dtypes are identical. index_values : Index | numpy.ndarray, default None Optional index (shared by both left and right), used in output. check_exact : bool, default False Whether to compare number exactly. .. versionchanged:: 2.2.0 Defaults to True for integer dtypes if none of ``check_exact``, ``rtol`` and ``atol`` are specified. rtol : float, default 1e-5 Relative tolerance. Only used when check_exact is False. atol : float, default 1e-8 Absolute tolerance. Only used when check_exact is False. obj : str, default 'ExtensionArray' Specify object name being compared, internally used to show appropriate assertion message. .. versionadded:: 2.0.0 Notes ----- Missing values are checked separately from valid values. A mask of missing values is computed for each and checked to match. The remaining all-valid values are cast to object dtype and checked. Examples -------- >>> from pandas import testing as tm >>> a = pd.Series([1, 2, 3, 4]) >>> b, c = a.array, a.array >>> tm.assert_extension_array_equal(b, c) Fr-r.zleft is not an ExtensionArrayzright is not an ExtensionArrayr_Attributes of r;rrN)rr<z NA mask)r<rpythonc6g|]}tj|SrAisnan.0vals rJ z0assert_extension_array_equal..5s = = =sRXc]] = = =rKzwrong missing value sentinelsc6g|]}tj|Srrrs rJrz0assert_extension_array_equal..=s ? ? ?sRXc]] ? ? ?rK)r_)r/r1r3r<r)"r no_defaultrr_r r=r#r`r'rOrrArrunit datetime_datar roperatoreqrrsrasi8isnar(rrnanto_numpyobjectrDrErF)rGrHr/rr7r1r3r<l_unitr_unitleft_naright_na left_valid right_valids rJrrs}h s~%% CN " " CN " " TZ ( ( /"4:... 0 ,,0"5;///   & & s~--446Ds~--446D dN + +LL-LLL + e^ , ,NN.NNN ,L'44JS4J4JKKKK 4/00 u4 5 5 KK4:: % % tz$66dj"(33 9otz::?)$*55a8ek2844 :ou{;;@)%+66q9&  2M5>8;#%%!  ! Jty ! ! Juz " "%     j%%Gz%**,,''H#///l 4:{+++ J ( * * J 26 ) )v = =dmG&< = = =   + + * + +  5; ,,+ K 8 + + K BF * *v ? ?enX&> ? ? ?   + + * + + wh((v(66J "++&+99K    <       $  [))%      rKr ) check_index check_likecheck_index_typecheck_series_typecheck_datetimelike_compat check_flagsrrc < d}|tjurdn|}|tjuro| tjura| tjurSt|jrt |j p(t|jot |j }n|tjurd}| tjur| nd} | tjur| nd} |s|rt dt ||t|rt|||t|t|krDt|d|j }t|d|j }t|d||| rC|j |j ks3Jt|j d t|j |r't|j |j ||||| | | |d  |r||}| rUt!|j t"t$fr4|j }|j }|j|jksJ|j|jf|rMt!|jt(rt!|jt(r|snt+d ||d ||r|j}|j}t!|t.r=t!|t.r(t1||||j t3|n9||}}t!|t.r|}t!|t.r|}t7|||t3||j n|rt9|jst9|jr]t;|jt;|js"d|jd|jd}t?|n4t!|jt@r6t!|jt@rtC|j"|j"nt!|jt(st!|jt(rFtGj$|j|j| | tK|t3||j njt!|jtLrNt!|jtLr4t1|j|j| | ||j t3|ntO|j|jstO|j|jr1t1|j|j||j t3|nt9|jrEt9|jr1t1|j|j||j t3|nDtGj$|j|j| | tK|t3||j |rt+d||||rVt!|jt(st!|jt(r$tQ|j|j|d| dSdSdS)a Check that left and right Series are equal. Parameters ---------- left : Series right : Series check_dtype : bool, default True Whether to check the Series dtype is identical. check_index_type : bool or {'equiv'}, default 'equiv' Whether to check the Index class, dtype and inferred_type are identical. check_series_type : bool, default True Whether to check the Series class is identical. check_names : bool, default True Whether to check the Series and Index names attribute. check_exact : bool, default False Whether to compare number exactly. .. versionchanged:: 2.2.0 Defaults to True for integer dtypes if none of ``check_exact``, ``rtol`` and ``atol`` are specified. check_datetimelike_compat : bool, default False Compare datetime-like which is comparable ignoring dtype. check_categorical : bool, default True Whether to compare internal Categorical exactly. check_category_order : bool, default True Whether to compare category order of internal Categoricals. check_freq : bool, default True Whether to check the `freq` attribute on a DatetimeIndex or TimedeltaIndex. check_flags : bool, default True Whether to check the `flags` attribute. rtol : float, default 1e-5 Relative tolerance. Only used when check_exact is False. atol : float, default 1e-8 Absolute tolerance. Only used when check_exact is False. obj : str, default 'Series' Specify object name being compared, internally used to show appropriate assertion message. check_index : bool, default True Whether to check index equivalence. If False, then compare only values. .. versionadded:: 1.3.0 check_like : bool, default False If True, ignore the order of the index. Must be False if check_index is False. Note: same labels must be with the same data. .. versionadded:: 1.5.0 Examples -------- >>> from pandas import testing as tm >>> a = pd.Series([1, 2, 3, 4]) >>> b = pd.Series([1, 2, 3, 4]) >>> tm.assert_series_equal(a, b) TFr-r.z0check_like must be False if check_index is Falser;rczSeries length are different != .indexr8rXr7rYrZr1r3r<r_r)r/rr<)r/r<rzatetimelike_compat=True] z is not equal to .)r1r3r/r<r)r1r3r/rr<namerl)r<rN))rrrr_r ValueErrorrRr rCrpindexroflagsrr> reindex_liker=rr!rrr`rwr#rr[rrsrrrvrNrr~rrDrErFr0is_extension_array_dtype_and_needs_i8_conversionr)rGrHr/r r rXr7r rYrrr r1r3r<rrrcheck_exact_indexrrlidxridx left_values right_valueslvrvrs rJr?r?SsmZ!,!>!>Ks~%% CN " " CN " " TZ ( ( /"4:... 0 ,,0"5;///   & & s~--446Ds~--446D M:MKLLLdE6***14C0000 4yyCJJd))++tz++e**-- --C!>dKKKWzU[(((T$*-=-=*V*V4 CTCT*V*V(((   J K"#)/& (  ''>jm^-LMM>z{yDI%%% 49'=%%% P tz#3 4 4 P5;(899 P& P  gtU8N8N8N O O O Oc l } k> 2 2 z .8 8   )'!ZHH      !,B+~66 , ))++,77 -!**,, $'HH!Z       #G DJ''G +>u{+K+KG T\""))% *>*>?? &4dl44#(=444 !%% %  & DJ . .8 : ]448  $DJ <<<< DJ 0 1 14 Z %664  $ L M[))C      DJ / /( J ^55(  % L M#C      : EK   9%+tz R R  % L M#C       TZ ( ( -@-M-M $ L M#C       $ L M[))C    8&$37777  dj"2 3 3 z K)8 8   %  %%%%9           rKrcheck_column_typecheck_frame_type by_blockscd}|tjur|nd}|tjur|nd}|tjur|nd}t||t|rt |t |sJ|j|jkr;t||dt|jt|j| rC|j |j ks3Jt|j dt|j t|j |j |||| | |||d t|j |j |||| | |||d  | r| |}|r|}|}tt!t|t|zD]-}||vsJ||vsJt%|||||| .dSt'|j D]Y\}}||d }||d }t+||||||| | | |d |d|d||ddZdS)a Check that left and right DataFrame are equal. This function is intended to compare two DataFrames and output any differences. It is mostly intended for use in unit tests. Additional parameters allow varying the strictness of the equality checks performed. Parameters ---------- left : DataFrame First DataFrame to compare. right : DataFrame Second DataFrame to compare. check_dtype : bool, default True Whether to check the DataFrame dtype is identical. check_index_type : bool or {'equiv'}, default 'equiv' Whether to check the Index class, dtype and inferred_type are identical. check_column_type : bool or {'equiv'}, default 'equiv' Whether to check the columns class, dtype and inferred_type are identical. Is passed as the ``exact`` argument of :func:`assert_index_equal`. check_frame_type : bool, default True Whether to check the DataFrame class is identical. check_names : bool, default True Whether to check that the `names` attribute for both the `index` and `column` attributes of the DataFrame is identical. by_blocks : bool, default False Specify how to compare internal data. If False, compare by columns. If True, compare by blocks. check_exact : bool, default False Whether to compare number exactly. .. versionchanged:: 2.2.0 Defaults to True for integer dtypes if none of ``check_exact``, ``rtol`` and ``atol`` are specified. check_datetimelike_compat : bool, default False Compare datetime-like which is comparable ignoring dtype. check_categorical : bool, default True Whether to compare internal Categorical exactly. check_like : bool, default False If True, ignore the order of index & columns. Note: index labels must match their respective rows (same as in columns) - same labels must be with the same data. check_freq : bool, default True Whether to check the `freq` attribute on a DatetimeIndex or TimedeltaIndex. check_flags : bool, default True Whether to check the `flags` attribute. rtol : float, default 1e-5 Relative tolerance. Only used when check_exact is False. atol : float, default 1e-8 Absolute tolerance. Only used when check_exact is False. obj : str, default 'DataFrame' Specify object name being compared, internally used to show appropriate assertion message. See Also -------- assert_series_equal : Equivalent method for asserting Series equality. DataFrame.equals : Check DataFrame equality. Examples -------- This example shows comparing two DataFrames that are equal but with columns of differing dtypes. >>> from pandas.testing import assert_frame_equal >>> df1 = pd.DataFrame({'a': [1, 2], 'b': [3, 4]}) >>> df2 = pd.DataFrame({'a': [1, 2], 'b': [3.0, 4.0]}) df1 equals itself. >>> assert_frame_equal(df1, df1) df1 differs from df2 as column 'b' is of a different type. >>> assert_frame_equal(df1, df2) Traceback (most recent call last): ... AssertionError: Attributes of DataFrame.iloc[:, 1] (column name="b") are different Attribute "dtype" are different [left]: int64 [right]: float64 Ignore differing dtypes in columns with check_dtype. >>> assert_frame_equal(df1, df2, check_dtype=False) Tr-r.Fz shape mismatchrrrz.columnsrr)axisz .iloc[:, z] (column name="z")) r/r r7rXr rYrr<r1r3rr N)rrrRrr=rOrrorrr>rcolumnsr_to_dict_of_blockslistsetkeysr@ enumerate_ixsr?)rGrHr/r rr rXr!r7r rYrrr r1r3r<r_rtol_atol _check_exactrblockslblocksr_icollcolrcols rJr@r@^s@\..DDFE..DDFE"-S^"C"C;;LdE9----$U ,,,,, zU[   C(((T$*-=-=*?DDUDUAW   WzU[(((T$*-=-=*V*V4 CTCT*V*V(((   +"N  NNN       +"N         (  ''%**,,))++#d7<<>>22T',,..5I5IIJJKK  EG####G#### KS         --  FAs99QQ9''D::aa:((D '!1''*C"3%??Q?????!!       rKc d}t|trTt||fi|t|ttfr&|j|jksJ|j|jfdSdSt|t rt||fi|dSt|trt||fi|dSt|trt||fi|dSt|trt||fi|dSt|trt||fi|dSt|t rt#||fi|dSt|t$rt'||fi|dSt|t(jrt-||fi|dSt|t.r|iksJ||ksJdS|iksJt1||dS)aC Wrapper for tm.assert_*_equal to dispatch to the appropriate test function. Parameters ---------- left, right : Index, Series, DataFrame, ExtensionArray, or np.ndarray The two items to be compared. **kwargs All keyword arguments are passed through to the underlying assert method. TN)r=rr>rr!rr r?rr@r$r~r%rr"rr&rr#rrArBrsr[rE)rGrHrIrs rJrr)sY$)411&111 d]N; < < D9 ***TY ,C*** D D** D& ! !)D%22622222 D) $ $)411&11111 D- ( ()#D%::6::::: D+ & &)!$8888888 D- ( ( )#D%::6::::: D. ) ) )$T5;;F;;;;; D. ) ) )$T5;;F;;;;; D"* % %) u7777777 D#  )||||u}}}}}}||||D%(((((rKct||tjjt |j|jt |jtsJt |jtsJ|j}|j}| |stdd||n td||td||t | | dS)z Check that the left and right SparseArray are equal. Parameters ---------- left : SparseArray right : SparseArray zSparseArray.indexzindex are not equal fill_valuer_N) rRrarrays SparseArrayrs sp_valuesr=sp_indexr rvror`to_dense)rGrH left_index right_indexs rJassert_sp_array_equalr>RsdE29#8999T^U_=== dm[ 1 111 1 enk 2 222 2J.K   [ ) )  !6 K    lD%000gtU+++T]]__enn.>.>?????rKcL|D] }||vsJdt|!dS)NzDid not contain item: )r)iterabledicks rJassert_contains_allrCss? <<Cxxx;$q'';;xxxx<O>O @ @ @ E!!!3!!!! ''rK left_dtyper+ right_dtypecJt|tot|S)z Checks that we have the combination of an ExtensionArraydtype and a dtype that should be converted to int64 Returns ------- bool Related to issue #37609 )r=rr)rKrLs rJrrs" j. 1 1 V6I+6V6VVrKserl_slcslicei_slcc|j|}t|j||t|jst|||dSdS)z_ Check that ser.iloc[i_slc] matches ser.loc[l_slc] and, if applicable, ser[l_slc]. N)ilocr?locrr)rNrOrQexpecteds rJ!assert_indexing_slices_equivalentrVs[ xH111 CI & &2CJ1111122rKDataFrame | SeriesDataFrame | Series | Nonecx|jD]1}t||d}||J|t||dksJ2dS)z: Check that ._metadata attributes are equivalent. N) _metadatar)rGrHrrs rJassert_metadata_equivalentr[s` 55dD$'' =;;;;'%t4444444 55rK)r,r-r.)r/r0r1r2r3r2r4r5)r4r5)T)rSrFr4r5)r,TTTTr-r.r)rGrrHrr8rWrXrFr7rFrYrFrZrFr1r2r3r2r<r[r4r5)Tr:)r8rWr<r[r4r5)r)rr[r<r[r4r5)TTr)r/rFrrFr<r[r4r5)r,r$)r8r0r<r[r4r5)r%rm)r"T)r<r[rrFr4r5)r&T)NNNr)FTNNr9N)rrFr/r0r<r[r4r5) r/r0r7rr1rr3rr<r[r4r5) r/r0r r0r rFrXrFr7rr rFrYrFrrFrrFr rFr1rr3rr<r[rrFrrFr4r5) r/r0r r0rr0r rFrXrFr!rFr7rr rFrYrFrrFrrFr rFr1rr3rr<r[r4r5)rKr+rLr+r4rF)rNr rOrPrQrPr4r5r)rGrWrHrXr4r5)[ __future__rrtypingrrrrnumpyrA pandas._libsrpandas._libs.missingr pandas._libs.sparser pandas._libs.testing_libstestingrDpandas._libs.tslibs.np_datetimer pandas.core.dtypes.commonr r rrrrpandas.core.dtypes.dtypesrrrrpandas.core.dtypes.missingrpandasrrrrrrrrrrr r!pandas.core.arraysr"r#r$r%r&pandas.core.arrays.datetimeliker'pandas.core.arrays.string_r(pandas.core.indexes.apir)pandas.io.formats.printingr*pandas._typingr+rErRrVr>rCr`rrrr~rrrrorsrrr?r@rr>rCrJrrVr[rrKrJrps3""""""//////++++++'''''''''JJJJJJ 877777                          CBBBBB222222333333333333('''''' ,3 O O O O O d    8GGGGG "hYhYhYhYhYX7>GGGGGD$$$$$N<<<<,>>>>!% :7:7:7:7:7|GV66666>55555AE 2 2 2 2 2BF88888IM)))))^+/ M=M=M=M=M=f,0(+"%."%.P P P P P n,007"(+&+"!%"%."%.G"%GGGGGG\,00718!(+&+""%."%.#HHHHHV&)&)&)&)R@@@@B<<<< ''''$ W W W W 2 2 2 2BF 5 5 5 5 5 5 5rK