zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
U
­ý°db'ã@sRddlZddlZddlZddlmZmZmZmZm    Z    ddl
m Z Gdd„dƒZ dS)éN)Ú    DataFrameÚ
RangeIndexÚSeriesÚconcatÚ
date_rangec @s^eZdZdd„Zdd„Zej dddg¡ej dgd    d
d gg¡d d „ƒƒZej de    j
e    j e    j fe    j
e    j e    j fde    j
e    j fde    je    j fde    j
e    j fde    je    j fddg¡dd„ƒZej dddddddg¡dd„ƒZej ddddddg¡ej ddddddg¡dd„ƒƒZdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„ZdS)3ÚTestEmptyConcatc    Cs6ttj dd¡tdƒd}|dd… ¡}d|d<|dd…}||||dd…g}t|d|d    }|jd
d d d dgd}|d d¡|d<d|j    dd…df<t
  ||¡tdt dƒit ddddd}tƒ}t||gdd}t
  ||¡t||gdd}t
  ||¡t||gƒ}t
  ||¡t||gƒ}t
  ||¡dS)Né
éZabcd©ÚcolumnséÚbarZfoor)ÚaxisÚsortÚaÚbÚcÚdÚOÚAi'Z20130101Ús)ZperiodsÚfreq©Úindexé©r)rÚnpÚrandomZrandnÚlistÚcopyrZreindexÚastypeÚlocÚtmÚassert_frame_equalÚranger)    ÚselfrÚdfZdfcopyÚemptyÚframesZ    concattedÚexpectedÚresult©r+ú]d:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/reshape/concat/test_empty.pyÚtest_handle_empty_objectss.  
ÿ     z)TestEmptyConcat.test_handle_empty_objectscCstdddgdd}tddd}t||gdd    }tdddgtjtjtjgd
œtdƒd }t ||¡tdddgdd}tddd}t||gd d    }tdddgƒ}t ||¡tdddgdd}tddd}t||gdd    }tdddgtjtjtjgd œdd gtdƒd}t ||¡dS)NrééÚx)ÚnameÚyÚfloat64)r1Údtyper)r0r2rr)r0r)r r)    rrrrÚnanrr"r#Úassert_series_equal)r%Ús1Ús2ÚresÚexpr+r+r,Útest_concat_empty_series0s, þ    ýz(TestEmptyConcat.test_concat_empty_seriesÚtzNÚUTCÚvaluesrr.r/cCsxtgddj |¡}|rdntj}t||d}tttjgt|ƒddj |¡|dœƒ}t    ||gdd}t
  ||¡dS)NúM8[ns]©r4)rrrr) rÚdtZ tz_localizerr3rÚpdZNaTÚlenrr"r#)r%r<r>Úfirstr4Úsecondr)r*r+r+r,Ú!test_concat_empty_series_timelikeMs þÿz1TestEmptyConcat.test_concat_empty_series_timelikezleft,right,expectedzm8[ns]r?)ÚcategoryrGrG)rGÚobjectrHcCs*tt|dt|dgƒ}|j|ks&t‚dS©Nr@)rrr4ÚAssertionError)r%ÚleftÚrightr)r*r+r+r,Útest_concat_empty_series_dtypes_sz/TestEmptyConcat.test_concat_empty_series_dtypesr4r3Zint8Zuint8ÚboolcCsRt |¡}tt|dgƒ}|j|ks(t‚tt|dt|dgƒ}|j|ksNt‚dSrI)rr4rrrJ)r%r4r*r+r+r,Ú0test_concat_empty_series_dtypes_match_roundtripsts
 
z@TestEmptyConcat.test_concat_empty_series_dtypes_match_roundtripsÚdtype2cst||kr dSdd„‰dd„‰‡‡fdd„}t |¡}t |¡}|||ƒ}tt|dt|dgƒj}|j|kspt‚dS)NcSsb|j|jh}t|dddhƒs6|jdks2|jdkr6dSt|ddhƒs^|jdksZ|jdkr^dSdS)NÚiÚur©ÚkindrC©r4rPZtypsr+r+r,Úint_result_typeŠs ÿÿÿÿzSTestEmptyConcat.test_concat_empty_series_dtypes_roundtrips.<locals>.int_result_typecSs:|j|jh}t|dddhƒs6|jdks2|jdkr6dSdS)NÚfrQrRrSrUr+r+r,Úfloat_result_type–s ÿÿzUTestEmptyConcat.test_concat_empty_series_dtypes_roundtrips.<locals>.float_result_typecs0ˆ||ƒ}|dk    r|Sˆ||ƒ}|dk    r,|SdS)Nrr+)r4rPr*©rXrVr+r,Úget_result_typežs
 
zSTestEmptyConcat.test_concat_empty_series_dtypes_roundtrips.<locals>.get_result_typer@)rr4rrrTrJ)r%r4rPrZr)r*r+rYr,Ú*test_concat_empty_series_dtypes_roundtrips€s     
 
 
z:TestEmptyConcat.test_concat_empty_series_dtypes_roundtripscCs4ttddttjdttjdgƒjtjks0t‚dS)Nr?r@)rrrÚbool_Úint64r4Úobject_rJ©r%r+r+r,Ú&test_concat_empty_series_dtypes_triple­s ÿýÿz6TestEmptyConcat.test_concat_empty_series_dtypes_triplecCs.ttt g¡ddtddgƒjdks*t‚dS)NrGr@r3)rrrÚarrayr4rJr_r+r+r,Ú2test_concat_empty_series_dtype_category_with_arrayµs ÿýÿzBTestEmptyConcat.test_concat_empty_series_dtype_category_with_arraycCs¤ttdd d¡tdd d¡gƒ}|jdks2t‚ttdd d¡tddgƒ}t tj¡}|j|ksjt‚ttdd d¡tddgƒ}t d¡}|j|ks t‚dS)Nr3r@ZSparsezSparse[float64]rH)    rrr r4rJrBZ SparseDtyperr3)r%r*r)r+r+r,Ú&test_concat_empty_series_dtypes_sparse¾s þÿÿ ÿ
z6TestEmptyConcat.test_concat_empty_series_dtypes_sparsecCsTtdddgtjdddgdœƒ}t|jd}t||gdd}| t¡}t ||¡dS)Nrrr.r/)ZRowZEmptyColZ    NumberColr
r)    rrr5r rr rHr"r#)r%Zdf_1Zdf_2r*r)r+r+r,Ú!test_concat_empty_df_object_dtypeÓs
 
z1TestEmptyConcat.test_concat_empty_df_object_dtypecCsættdƒd}|d tj¡|d<|d tj¡|d<|d tj¡|d<t||gƒ}|djtjksjt    ‚|djtjks~t    ‚|djtjks’t    ‚t|| tj¡gƒ}|djtj
ksºt    ‚|djtjksÎt    ‚|djtjksât    ‚dS)NÚabcr
rrr) rrr rr\Úint32r3rr4rJr^)r%r&r*r+r+r,Ú"test_concat_empty_dataframe_dtypesÛs z2TestEmptyConcat.test_concat_empty_dataframe_dtypescCsrtƒ}tdddgiddgdd}tdgitdƒdd}d|fd|ffD]&\}}t||gd|d    }t ||¡qFdS)
Nrrr.rr])rr4ÚinnerÚouter)rÚjoin)rrrr"r#)r%Údf_emptyZdf_aZ df_expectedÚhowr)r*r+r+r,Útest_concat_inner_join_emptyës z,TestEmptyConcat.test_concat_inner_join_emptycCs\tddgddggddgd}tddgddggddgd}t||gƒ}|j}t |j|¡dS)Nrr.rr)Údatar r/r    )rrZdtypesr"r6)r%Údf1Údf2r*r)r+r+r,Útest_empty_dtype_coerceõs
 z'TestEmptyConcat.test_empty_dtype_coercecCsŠtddgd}tddgd}t|||gƒ}tdddgd}t ||¡tddgd}tdgd}t||gƒ}tddgd}t ||¡dS)Nrrr
r)rrr"r#)r%rorpr*r)Zdf3Zdf4r+r+r,Útest_concat_empty_dataframes   z+TestEmptyConcat.test_concat_empty_dataframecCsttdddgdddgdœƒ}tddddgiƒ}t|dd…|dd…gƒ}|djtjks\t‚|djtjkspt‚dS)    Nrr.r/rrr)rrr)rrr4rr]rJr^)r%rorpr*r+r+r,Ú,test_concat_empty_dataframe_different_dtypess
z<TestEmptyConcat.test_concat_empty_dataframe_different_dtypescCs^tdtjgt ¡diƒ}tdtjdddgt ¡diƒ}| ¡}t||gƒ}t ||¡dS)z<48510 `concat` to an empty EA should maintain type EA dtype.rr@rr.r/N)rrBraZ
Int64Dtyperrr"r#)r%rkZdf_newr)r*r+r+r,Útest_concat_to_empty_eas
  z'TestEmptyConcat.test_concat_to_empty_ea)Ú__name__Ú
__module__Ú __qualname__r-r;ÚpytestÚmarkZ parametrizerFrr\rfr^Úfloat32r]rMrOr[r`rbrcrdrgrmrqrrrsrtr+r+r+r,rsN      õþ
ÿ
     þ (    
     r)ÚnumpyrrxZpandasrBrrrrrZpandas._testingZ_testingr"rr+r+r+r,Ú<module>s