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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
U
­ý°d<ã@sVddlZddlZddlmZddlZddlmZmZm    Z    ddl
m Z Gdd„dƒZ dS)éN)Úunion_categoricals)Ú CategoricalÚCategoricalIndexÚSeriesc@sÖeZdZej dedƒedƒedƒfdddgddd    gdddddd    gfdd
dgdd d    gdd
ddd d    gfd d ejd gd ejdgd d ejd d ejdgfe     
dd¡e     
dd¡e     
dd¡fe    j
dddde    j
dddde    j
ddddfe      dd¡e      dd¡e      dd¡fg¡ej de e eg¡dd„ƒƒZdd„Zdd„Zdd„Zdd„Zd d!„Zej d"gd#gg¡d$d%„ƒZd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Zd2d3„Zd4d5„Zd6d7„Zd8d9„Zd:d;„Z d<d=„Z!d>d?„Z"d@dA„Z#dBS)CÚTestUnionCategoricalsza, b, combinedÚabcZabdZabcabdrééééç333333ó?g333333 @ÚbÚaÚcz
2014-01-01z
2014-01-05z
2014-01-06z
2014-01-07z
US/Central)ÚtzÚboxcCs4t|t|ƒƒ|t|ƒƒgƒ}t|ƒ}t ||¡dS©N©rrÚtmÚassert_categorical_equal)Úselfrr ZcombinedrÚresultÚexpected©rúcd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/reshape/test_union_categoricals.pyÚtest_union_categoricalsz,TestUnionCategoricals.test_union_categoricalcCs\tdddgƒ}tdddgƒ}t||gƒ}tddddddgddddddgd}t ||¡dS)NÚxÚyÚzrr r©Ú
categories©rrrr©rÚsÚs2rrrrrÚ)test_union_categorical_ordered_appearance3s ÿz?TestUnionCategoricals.test_union_categorical_ordered_appearancecCsXtdddgdd}tdddgdd}t||gƒ}tddddddgdd}t ||¡dS)Nrr r    T©Úorderedr!r"rrrÚ#test_union_categorical_ordered_true=s
 z9TestUnionCategoricals.test_union_categorical_ordered_truec    CsJtdddgƒ}tdddgƒ}d}tjt|dt||gƒW5QRXdS)Nrr r    r
r z$dtype of categories must be the same©Úmatch)rÚpytestÚraisesÚ    TypeErrorr)rr#r$ÚmsgrrrÚ"test_union_categorical_match_typesDs
z8TestUnionCategoricals.test_union_categorical_match_typesc    Cs*d}tjt|dtgƒW5QRXdS)NzNo Categoricals to unionr))r+r,Ú
ValueErrorr)rr.rrrÚtest_union_categorical_emptyLsz2TestUnionCategoricals.test_union_categorical_emptycCs’ttddtjgƒtddtjgƒgƒ}tddtjddtjgƒ}t ||¡ttddgƒtddtjgƒgƒ}tddddtjgƒ}t ||¡t d¡t d¡tjg}tjt d¡t d¡g}tt|ƒt|ƒgƒ}t||t d¡t d¡t d¡gd    }t ||¡tttj    tjtjgt
d
ƒtd gƒgƒ}ttjtjd gƒ}t ||¡tttjtjgƒttjtjgƒgƒ}ttjtjtjtjgƒ}t ||¡dS) Nrr    r
ÚAÚBz
2011-01-01z
2011-03-01z
2011-02-01r©ZdtypeÚX) rrÚnpÚnanrrÚpdÚ    TimestampZNaTÚarrayÚobject)rÚresÚexpZval1Zval2rrrÚtest_union_categoricals_nanQsBÿ ÿ ýþ þÿ ÿz1TestUnionCategoricals.test_union_categoricals_nanÚvalÚ1cCs,ttgƒt|ƒgƒ}t|ƒ}t ||¡dSrr)rr?r<r=rrrÚtest_union_categoricals_empty}sz3TestUnionCategoricals.test_union_categoricals_emptyc    Cs|tddddgddddgd}tdddtjgddddgd}t||gƒ}tdddddddtjgddddgd}t ||¡dS)Nrr    r
r r©rr6r7rrr©rÚc1Úc2r<r=rrrÚ$test_union_categorical_same_category„s
 &z:TestUnionCategoricals.test_union_categorical_same_categorycCsjtdddgdddgd}tdddgdddgd}t||gƒ}tddddddgdddgd}t ||¡dS)Nrrrrr!rCrrrÚ(test_union_categorical_same_category_strŒs
 z>TestUnionCategoricals.test_union_categorical_same_category_strcCsjtdddgdddgd}tdddgdddgd}t||gƒ}tddddddgdddgd}t ||¡dS)Nrr rrr!©rrDrErrrrrÚ6test_union_categorical_same_categories_different_order“s ÿzLTestUnionCategoricals.test_union_categorical_same_categories_different_orderc    Cs8tdddgdd}tdddgdd}d}tjt|dt||gƒW5QRXt||gƒ}tddddddgdd}t ||¡tdddtjgdd}tddgdddgdd    }t||gƒ}tdddtjddgdd}t ||¡tdddgdd}tdddgdddgdd    }d
}tjt|dt||gƒW5QRXdS) Nrr    r
Tr&Fú$Categorical.ordered must be the samer)©r r'ú>to union ordered Categoricals, all categories must be the same)    rr+r,r-rrrr6r7)rrDrEr.r<r=rrrÚtest_union_categoricals_ordereds$    z5TestUnionCategoricals.test_union_categoricals_orderedc    Cs’tdddgdd}tdddgdd}t||gdd}tddddddgƒ}t ||¡d}tjt|d    t||gddW5QRXt||gdd}tddddddgƒ}t ||¡t||gdd}tddddddgdddgdd
}t ||¡tdddtjgdd}tddgdddgdd
}t||gdd}tdddtjddgƒ}t ||¡tdddgdd}tdddgdddgdd
}t||gdd}tddddddgƒ}t ||¡t||gddd }tddddddgdddgd }t ||¡tdddgdd}td ddgdd}t||gdd}tdddd ddgƒ}t ||¡d}tjt|d    t||gddW5QRXtjt|d    t||gƒW5QRXdS)Nrr    r
Tr&F)Ú ignore_orderrJr)rK)rNÚsort_categoriesrr éérL)    rrrrr+r,r-r6r7)rrDrEr<r=r.rrrrrÚ$test_union_categoricals_ignore_order·sJ        z:TestUnionCategoricals.test_union_categoricals_ignore_orderc    Cs°tdddgƒ}tdddgƒ}t||gdd}tddddddgddddddgd    }t ||¡tddgdddgd    }tddgdddgd    }t||gdd}tddddgdddgd    }t ||¡tddgdddgd    }tddgdddgd    }t||gdd}tddddgdddgd    }t ||¡tddgdddgd    }tddgdddgd    }t||gdd}tddddgdddgd    }t ||¡tdtjgƒ}ttjdgƒ}t||gdd}tdtjtjdgddgd    }t ||¡ttjgƒ}ttjgƒ}t||gdd}ttjtjgƒ}t ||¡tgƒ}tgƒ}t||gdd}tgƒ}t ||¡tddgdddgdd
}tddgdddgdd
}d }tjt|d t||gddW5QRXdS) Nrrrrr rT©rOrrKz9Cannot use sort_categories=True with ordered Categoricalsr))    rrrrr6r7r+r,r-©rrDrErrr.rrrÚtest_union_categoricals_sortësVÿ         z2TestUnionCategoricals.test_union_categoricals_sortcCs`tdddgƒ}tdddgƒ}t||gdd}tddddddgddddddgd    }t ||¡dS)
Nrrrrr rFrSrr!rHrrrÚ"test_union_categoricals_sort_false!sÿz8TestUnionCategoricals.test_union_categoricals_sort_falsecCsftddgdddgd}tddgdddgd}t||gdd}tddddgdddgd}t ||¡dS©Nrr rrFrSr!rHrrrÚ+test_union_categoricals_sort_false_fastpath+s
zATestUnionCategoricals.test_union_categoricals_sort_false_fastpathcCsftddgdddgd}tddgdddgd}t||gdd}tddddgdddgd}t ||¡dSrWr!rHrrrÚ-test_union_categoricals_sort_false_skipresort3s
zCTestUnionCategoricals.test_union_categoricals_sort_false_skipresortcCsXtdtjgƒ}ttjdgƒ}t||gdd}tdtjtjdgddgd}t ||¡dS)Nrr FrSrrBrHrrrÚ*test_union_categoricals_sort_false_one_nan;s
z@TestUnionCategoricals.test_union_categoricals_sort_false_one_nancCsHttjgƒ}ttjgƒ}t||gdd}ttjtjgƒ}t ||¡dS©NFrSrBrHrrrÚ+test_union_categoricals_sort_false_only_nanBs
  zATestUnionCategoricals.test_union_categoricals_sort_false_only_nancCs8tgƒ}tgƒ}t||gdd}tgƒ}t ||¡dSr[r!rHrrrÚ(test_union_categoricals_sort_false_emptyIs
z>TestUnionCategoricals.test_union_categoricals_sort_false_emptycCsltddgdddgdd}tddgdddgdd}t||gdd}tddddgdddgdd}t ||¡dS)Nr rrTrKFrSr!rHrrrÚ/test_union_categoricals_sort_false_ordered_truePs
ÿzETestUnionCategoricals.test_union_categoricals_sort_false_ordered_truec    Cs¸tddgƒ}tddgdd}t||gƒ}tddddgƒ}t ||¡t|ƒ}t||gƒ}t ||¡t|ƒ}t||gƒ}t ||¡d}tjt|dt|dddggƒW5QRXdS)Nrr rÚcategoryr4z-all components to combine must be Categoricalr))    rrrrrrr+r,r-rTrrrÚtest_union_categorical_unwrapYs       z3TestUnionCategoricals.test_union_categorical_unwrapN)$Ú__name__Ú
__module__Ú __qualname__r+ÚmarkZ parametrizeÚlistr6r7r8Z
date_rangeZ period_rangerrrrr%r(r/r1r>rArFrGrIrMrRrUrVrXrYrZr\r]r^r`rrrrrs\   
ý
 
 
ýý
 
 
ýíþ 
,
 
46
    r)Únumpyr6r+Zpandas.core.dtypes.concatrZpandasr8rrrZpandas._testingZ_testingrrrrrrÚ<module>s