zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
U
¬ý°d¥Pã @sæddlmZddlmZddlmZddlZddlmZddl    m
Z
m Z m Z m Z mZmZmZmZddlZddlmZddlmZmZmZdd    lmZdd
lmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'dd l(m)Z*dd l+m,Z,dd l-m.Z.m/Z/ddl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@ddlAmBZBmCZCddlDmEZEmFZFddlGmHZHmIZIddlJmKZKmLZLmMZMddlNmOZOmPZPddlQmRZRmSZSddlTmUZUmVZVddlWmXZXmYZYmZZZddl[m\m]Z^ddl_m`Z`maZaddlbmcZcddldmeZeddlfmgZgddlhmiZie
r(ddljmkZkmlZlmmZmedddZnd d!„Zod"d#œd$d%„ZpGd&d„deUeZegƒZqePeqd'd(gd)d*ePeqd+d,d-d.d/d0d1d2gd3d*Gd4d5„d5eOeZeYƒƒƒZrd6d7d8œd9d:„ZsdEd7d"d7d<œd=d>„Ztd?d#œd@dA„ZudBd#œdCdD„ZvdS)Fé)Ú annotations)ÚQUOTE_NONNUMERIC)ÚpartialN)Úget_terminal_size)Ú TYPE_CHECKINGÚHashableÚIteratorÚLiteralÚSequenceÚTypeVarÚcastÚoverload)Ú
get_option)ÚNaTÚalgosÚlib)Ú NDArrayBacked)
Ú    ArrayLikeÚ    AstypeArgÚAxisIntÚDtypeÚNpDtypeÚOrderedÚShapeÚSortKindÚnptÚtype_t)Úfunction)Úvalidate_bool_kwarg)Úcoerce_indexer_dtypeÚfind_common_type)Ú ensure_int64Úensure_platform_intÚis_any_real_numeric_dtypeÚ is_bool_dtypeÚis_categorical_dtypeÚis_datetime64_dtypeÚ is_dict_likeÚis_dtype_equalÚis_extension_array_dtypeÚ is_hashableÚis_integer_dtypeÚ is_list_likeÚ    is_scalarÚis_timedelta64_dtypeÚneeds_i8_conversionÚ pandas_dtype)ÚCategoricalDtypeÚExtensionDtype)ÚABCIndexÚ    ABCSeries)Úis_valid_na_for_dtypeÚisna)Ú
algorithmsÚ    arraylikeÚops)ÚPandasDelegateÚdelegate_names)Ú    factorizeÚtake_nd)ÚNDArrayBackedExtensionArrayÚ ravel_compat)ÚExtensionArrayÚNoNewAttributesMixinÚ PandasObject)Ú extract_arrayÚsanitize_array)Úunpack_zerodim_and_defer)Únargsort)ÚObjectStringArrayMixin)Úconsole)Ú    DataFrameÚIndexÚSeriesÚ CategoricalTÚ Categorical)Úboundcs:dˆj›d‰ˆtjk‰tˆƒ‡‡‡fdd„ƒ}ˆ|_|S)NÚ__cs‚t|ƒ}t|ƒr,t|ƒt|ƒkr,|s,tdƒ‚|jsBˆdkrBtdƒ‚t|tƒrÆd}| |¡sbt|ƒ‚|jsŽ|j     
|j    ¡sŽt |j |j    |j    dd}n|j }ˆ|j |ƒ}|j dk|dkB}| ¡rˆ||<|S|r||j    kr| |¡}ˆ|j |ƒ}ˆdkr
|j dk}ˆ||<|St ||ˆ¡Sn`ˆd    krBtd
ˆ›d t|ƒ›d ƒ‚t|tƒrdt|jƒrdˆ||ƒStt |¡ˆƒt |¡ƒSdS) NzLengths must match.)Ú__lt__Ú__gt__Ú__le__Ú__ge__z7Unordered Categoricals can only compare equality or notz?Categoricals can only be compared if 'categories' are the same.F©Úcopyéÿÿÿÿ>Ú__eq__rQrS)rWÚ__ne__z$Cannot compare a Categorical for op z  with type zB.
If you want to compare values, use 'np.asarray(cat) <op> other'.)r*r,ÚlenÚ
ValueErrorÚorderedÚ    TypeErrorÚ
isinstancerMÚ#_categories_match_up_to_permutationÚ
categoriesÚequalsÚrecode_for_categoriesÚcodesÚ_codesÚanyÚ _unbox_scalarr9Zinvalid_comparisonÚtyper@r/ÚdtypeÚgetattrÚnpÚarray)ÚselfÚotherZhashableÚmsgZ other_codesÚretÚmaskÚi©Ú
fill_valueÚopÚopname©úUd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/arrays/categorical.pyÚfunc~sRÿ
 
ÿ  
 
 
 
ÿ
z_cat_compare_op.<locals>.func)Ú__name__ÚoperatorÚnerE)rsrwrurqrvÚ_cat_compare_opzs 
?r{Úbool©Úreturnc    s^t|ƒz|j |¡}Wnttfk
r2YdSXt|ƒrD|ˆkSt‡fdd„|DƒƒSdS)aO
    Helper for membership check for ``key`` in ``cat``.
 
    This is a helper method for :method:`__contains__`
    and :class:`CategoricalIndex.__contains__`.
 
    Returns True if ``key`` is in ``cat.categories`` and the
    location of ``key`` in ``categories`` is in ``container``.
 
    Parameters
    ----------
    cat : :class:`Categorical`or :class:`categoricalIndex`
    key : a hashable object
        The key to check membership for.
    container : Container (e.g. list-like or mapping)
        The container to check for membership in.
 
    Returns
    -------
    is_in : bool
        True if ``key`` is in ``self.categories`` and location of
        ``key`` in ``categories`` is in ``container``, else False.
 
    Notes
    -----
    This method does not check for NaN values. Do that separately
    before calling this method.
    Fc3s|]}|ˆkVqdS©Nru)Ú.0Zloc_©Ú    containerrurvÚ    <genexpr>ószcontains.<locals>.<genexpr>N)Úhashr_Úget_locÚKeyErrorr\r-rd)ÚcatÚkeyr‚ÚlocrurrvÚcontainsÃsrŠcs~eZdZUdZdZejedgƒBZdZde    d<dÜd
d d d d œ‡fdd„ Z
e ddœdd„ƒZ e ddœdd„ƒZ edddœd
d ddœdd„ƒZedÝdd ddœdd„ƒZedÞdd d dœd!d„ƒZedßd"d d#dœd$d„ƒZdàd"d d#dœ‡fd%d„ Zd&d'„Zedád(d)„ƒZedâd
dd*œd+d,„ƒZe d-dœd.d/„ƒZe d0dœd1d2„ƒZe ddœd3d4„ƒZdãd d d5œ‡fd6d7„ Zddd*œd8d9„Zd dd:œd;d<„Zddœd=d>„Zddœd?d@„Zdäd dAœdBdC„ZddœdDdE„ZdådFdG„ZddœdHdI„Z dJdK„Z!ddœdLdM„Z"dNdO„Z#e$e%j&ƒZ'e$e%j(ƒZ)e$e%j*ƒZ+e$e%j,ƒZ-e$e%j.ƒZ/e$e%j0ƒZ1dPdQ„Z2dRdS„Z3e4dædTdd*œdUdV„ƒZ5dWdXdYœdZd[„Z6d dœ‡fd\d]„ Z7e ddœd^d_„ƒZ8dçd dd`œdadb„Z9ddœdcdd„Z:e:Z;ddœdedf„Z<e<Z=dèd dgdhœdidj„Z>edkdldddmœdndo„ƒZ?dpdq„Z@d dœdrds„ZAd    dtduœd dvduœ‡fdwdx„ZBeddddyœdzd dXdd{œd|d}„ƒZCeddd~œdd dXd d{œd€d}„ƒZCdd    ddyœd d dXd‚d{œdƒd}„ZCd„d…d†d    dd‡œdˆdXdXd d d‡œd‰dŠ„ZDd‹dŒ„ZEe ddœddŽ„ƒZFddœdd‘„ZGddœd’d“„ZHd”dœd•d–„ZId dœd—d˜„ZJdéd d™œdšd›„ZKdêdd dXdœdždŸ„ZLd dœd¡d¢„ZMdXdœd£d¤„ZNdXdœd¥d¦„ZOdëd dXd dXd¨œd©dª„ZPdXdœd«d¬„ZQd­d®„ZRd¯dœd°d±„ZSd    d²œd d²œd³d´„ZTd    d²œd d²œdµd¶„ZUdìd ddhœd·d¸„ZV‡fd¹dº„ZWddd»œd¼d½„ZXd¾d d¿œdÀdÁ„ZYedídÂdÃdˆdÄdŜdÆdDŽƒZZddd¿œdÈdɄZ[dd d¿œdÊd˄Z\dÌdœdÍd΄Z]dÏdœdÐdфZ^ddҜd dҜdÓdԄZ_e`jae`  d¾¡d    fd d՜dÖdׄZbdîdXdٜdÚdۄZc‡ZdS)ïrMaY
    Represent a categorical variable in classic R / S-plus fashion.
 
    `Categoricals` can only take on a limited, and usually fixed, number
    of possible values (`categories`). In contrast to statistical categorical
    variables, a `Categorical` might have an order, but numerical operations
    (additions, divisions, ...) are not possible.
 
    All values of the `Categorical` are either in `categories` or `np.nan`.
    Assigning values outside of `categories` will raise a `ValueError`. Order
    is defined by the order of the `categories`, not lexical order of the
    values.
 
    Parameters
    ----------
    values : list-like
        The values of the categorical. If categories are given, values not in
        categories will be replaced with NaN.
    categories : Index-like (unique), optional
        The unique categories for this categorical. If not given, the
        categories are assumed to be the unique values of `values` (sorted, if
        possible, otherwise in the order in which they appear).
    ordered : bool, default False
        Whether or not this categorical is treated as a ordered categorical.
        If True, the resulting categorical will be ordered.
        An ordered categorical respects, when sorted, the order of its
        `categories` attribute (which in turn is the `categories` argument, if
        provided).
    dtype : CategoricalDtype
        An instance of ``CategoricalDtype`` to use for this categorical.
 
    Attributes
    ----------
    categories : Index
        The categories of this categorical
    codes : ndarray
        The codes (integer positions, which point to the categories) of this
        categorical, read only.
    ordered : bool
        Whether or not this Categorical is ordered.
    dtype : CategoricalDtype
        The instance of ``CategoricalDtype`` storing the ``categories``
        and ``ordered``.
 
    Methods
    -------
    from_codes
    __array__
 
    Raises
    ------
    ValueError
        If the categories do not validate.
    TypeError
        If an explicit ``ordered=True`` is given but no `categories` and the
        `values` are not sortable.
 
    See Also
    --------
    CategoricalDtype : Type for categorical data.
    CategoricalIndex : An Index with an underlying ``Categorical``.
 
    Notes
    -----
    See the `user guide
    <https://pandas.pydata.org/pandas-docs/stable/user_guide/categorical.html>`__
    for more.
 
    Examples
    --------
    >>> pd.Categorical([1, 2, 3, 1, 2, 3])
    [1, 2, 3, 1, 2, 3]
    Categories (3, int64): [1, 2, 3]
 
    >>> pd.Categorical(['a', 'b', 'c', 'a', 'b', 'c'])
    ['a', 'b', 'c', 'a', 'b', 'c']
    Categories (3, object): ['a', 'b', 'c']
 
    Missing values are not included as a category.
 
    >>> c = pd.Categorical([1, 2, 3, 1, 2, 3, np.nan])
    >>> c
    [1, 2, 3, 1, 2, 3, NaN]
    Categories (3, int64): [1, 2, 3]
 
    However, their presence is indicated in the `codes` attribute
    by code `-1`.
 
    >>> c.codes
    array([ 0,  1,  2,  0,  1,  2, -1], dtype=int8)
 
    Ordered `Categoricals` can be sorted according to the custom order
    of the categories and can have a min and max value.
 
    >>> c = pd.Categorical(['a', 'b', 'c', 'a', 'b', 'c'], ordered=True,
    ...                    categories=['c', 'b', 'a'])
    >>> c
    ['a', 'b', 'c', 'a', 'b', 'c']
    Categories (3, object): ['c' < 'b' < 'a']
    >>> c.min()
    'c'
    ièÚtolistZ categoricalr1Ú_dtypeNFTz Dtype | Noner|ÚNone)rgÚfastpathrUr~c
s^t ˆ|||¡}|rBtˆ|jƒ}tdd |¡}tƒ ||¡dStˆƒsRtdƒ‚t     
d¡}t ˆƒr~|jdkr|tˆj|j ƒ}nÖt ˆtttfƒsTt ˆ¡‰t ˆtƒrÀtˆƒdkrÀt    j
gtd‰n”t ˆt    jƒrêˆjdkrÞtdƒ‚tˆdƒ‰njtˆdƒ}    t|    ƒ}| ¡rP‡fdd    „t     |¡dDƒ}
|
s6|    jd
kr<d} n|    j} t|
d| d}    |    ‰|jdkrÊztˆd d \}}WnFtk
rº} z&tˆdd \}}|j rªtd ƒ| ‚W5d} ~ XYnXt||j ƒ}n:t ˆjƒrøtˆƒj } t!| ˆjj|j|d}n t"ˆ|jƒ}| ¡r0t    j#|j$|jd }|||<|}tdd |¡}t||jƒ}    tƒ |    |¡dS)NF©r[z#Categorical input must be list-liker©rgéz3> 1 ndim Categorical are not supported at this timecsg|] }ˆ|‘qSruru)r€Úidx©ÚvaluesrurvÚ
<listcomp>œsz(Categorical.__init__.<locals>.<listcomp>ÚobjectT)Úsortzl'values' is not ordered, please explicitly specify the categories order by passing in a categories argument.rT)%r1Ú_from_values_or_dtyperr_Ú update_dtypeÚsuperÚ__init__r,r\rirjr%r[r]r3r4r@ÚcomZconvert_to_list_likeÚlistrYr–ÚndarrayÚndimÚNotImplementedErrorrDr6rdÚwherergr<rCrcraÚ_get_codes_for_valuesZonesÚshape)rkr”r_r[rgrŽrUrbÚ    null_maskÚarrZarr_listZsanitize_dtypeÚerrZ    old_codesZ
full_codes©Ú    __class__r“rvr›gs€    ÿ 
 
 
 
ÿ 
 
 ÿü 
ÿ 
 
 zCategorical.__init__r}cCs|jS)zT
        The :class:`~pandas.api.types.CategoricalDtype` for this instance.
        )rŒ©rkrururvrgËszCategorical.dtypeÚintcCs|jj}| d¡S©NrV)Ú_ndarrayrgrf)rkrgrururvÚ_internal_fill_valueÒsz Categorical._internal_fill_value©rgrU)rgrUr~cCst|||dS)Nr®)rM)ÚclsZscalarsrgrUrururvÚ_from_sequenceÙszCategorical._from_sequence.z npt.DTypeLikeú
np.ndarraycCsdSrru©rkrgrUrururvÚastypeßszCategorical.astyper2r@cCsdSrrur²rururvr³ãsrrcCsdSrrur²rururvr³çsc    s^t|ƒ}|j|kr&|r| ¡n|}n4t|ƒr`tt|ƒ}|j |¡}|rP| ¡n|}| |¡}nút|t    ƒrzt
ƒj ||dSt |ƒr˜|  ¡ ¡r˜tdƒ‚nÂt|jƒdks´t|jƒdkrÆtj|||d}n”|jj}z@|j ||d}|jj}t||ƒs t t |jj¡  |¡¡}Wn6ttfk
rDd|jj›d|›}t|ƒ‚YnXt|t|jƒ|d}|S)aZ
        Coerce this type to another dtype
 
        Parameters
        ----------
        dtype : numpy dtype or pandas type
        copy : bool, default True
            By default, astype always returns a newly allocated object.
            If copy is set to False and dtype is categorical, the original
            object is returned.
        rTz#Cannot convert float NaN to integerrr®z Cannot cast z
 dtype to ©rr)r0rgrUr%r r1r™Ú
_set_dtyper]r2ršr³r+r6rdrZrYrbr_rirjÚ_valuesZ    _na_valuer5rZitem_from_zerodimr\r=r"rc)rkrgrUÚresultZnew_catsrrrmr§rurvr³ësL 
 
 
 
ý ÿþÿcCs| ¡S)z#
        Alias for tolist.
        )r‹r©rururvÚto_list(szCategorical.to_listcCs ddlm}m}m}m}||ƒ}    t|tƒo2|jdk    }
|
r¦t|jƒrP||dd}    nVt    |jƒrh||dd}    n>t
|jƒr€||dd}    n&t |jƒr¦|dkrœdddg}|      |¡}    |
r¾|j} t ||    | ƒ} n@|    jsî|     ¡} |     ¡} t || | ƒ} t| d    d
}nt|    d    d
}|} || |d d S) aA
        Construct a Categorical from inferred values.
 
        For inferred categories (`dtype` is None) the categories are sorted.
        For explicit `dtype`, the `inferred_categories` are cast to the
        appropriate type.
 
        Parameters
        ----------
        inferred_categories : Index
        inferred_codes : Index
        dtype : CategoricalDtype or 'category'
        true_values : list, optional
            If none are provided, the default ones are
            "True", "TRUE", and "true."
 
        Returns
        -------
        Categorical
        r)rJÚ to_datetimeÚ
to_numericÚ to_timedeltaNZcoerce)ÚerrorsÚTrueÚTRUEÚtrueFrT©rgrŽ)ÚpandasrJr¹rºr»r]r1r_r#r&r.r$ÚisinraZis_monotonic_increasingrUÚ sort_values)r¯Zinferred_categoriesZinferred_codesrgZ true_valuesrJr¹rºr»ZcatsZknown_categoriesr_rbZunsortedrururvÚ_from_inferred_categories.s4ÿ
 
 
 
 
 
  z%Categorical._from_inferred_categories)rgr~cCs¸tj|||d}|jdkr&d}t|ƒ‚t|ƒrZt|ƒrZt|ƒ ¡rJtdƒ‚|jt    j
d}n
t      |¡}t |ƒr|t|ƒs|tdƒ‚t |ƒrª|  ¡t |jƒks¢| ¡dkrªtdƒ‚|||d    d
S) aÖ
        Make a Categorical type from codes and categories or dtype.
 
        This constructor is useful if you already have codes and
        categories/dtype and so do not need the (computation intensive)
        factorization step, which is usually done on the constructor.
 
        If your data does not follow this convention, please use the normal
        constructor.
 
        Parameters
        ----------
        codes : array-like of int
            An integer array, where each integer points to a category in
            categories or dtype.categories, or else is -1 for NaN.
        categories : index-like, optional
            The categories for the categorical. Items need to be unique.
            If the categories are not given here, then they must be provided
            in `dtype`.
        ordered : bool, optional
            Whether or not this categorical is treated as an ordered
            categorical. If not given here or in `dtype`, the resulting
            categorical will be unordered.
        dtype : CategoricalDtype or "category", optional
            If :class:`CategoricalDtype`, cannot be used together with
            `categories` or `ordered`.
 
        Returns
        -------
        Categorical
 
        Examples
        --------
        >>> dtype = pd.CategoricalDtype(['a', 'b'], ordered=True)
        >>> pd.Categorical.from_codes(codes=[0, 1, 0, 1], dtype=dtype)
        ['a', 'b', 'a', 'b']
        Categories (2, object): ['a' < 'b']
        )r_r[rgNzKThe categories must be provided in 'categories' or 'dtype'. Both were None.zcodes cannot contain NA valuesrz$codes need to be array-like integersrVz1codes need to be between -1 and len(categories)-1TrÀ)r1r˜r_rZr)r+r6rdÚto_numpyriÚint64ÚasarrayrYÚmaxÚmin)r¯rbr_r[rgrmrururvÚ
from_codesss&*ÿ
ÿ 
&zCategorical.from_codesrJcCs|jjS)a¸
        The categories of this categorical.
 
        Setting assigns new values to each category (effectively a rename of
        each individual category).
 
        The assigned value has to be a list-like object. All items must be
        unique and the number of items in the new categories must be the same
        as the number of items in the old categories.
 
        Raises
        ------
        ValueError
            If the new categories do not validate as categories or if the
            number of new categories is unequal the number of old categories
 
        See Also
        --------
        rename_categories : Rename categories.
        reorder_categories : Reorder categories.
        add_categories : Add new categories.
        remove_categories : Remove the specified categories.
        remove_unused_categories : Remove categories which are not used.
        set_categories : Set the categories to the specified ones.
        )rgr_r©rururvr_¹szCategorical.categoriesrcCs|jjS)zF
        Whether the categories have an ordered relationship.
        )rgr[r©rururvr[ÖszCategorical.orderedcCs|j ¡}d|j_|S)a¢
        The category codes of this categorical.
 
        Codes are an array of integers which are the positions of the actual
        values in the categories array.
 
        There is no setter, use the other categorical methods and the normal item
        setter to change values in the categorical.
 
        Returns
        -------
        ndarray[int]
            A non-writable view of the `codes` array.
        F)rcÚviewÚflagsZ    writeable)rkÚvrururvrbÝs
zCategorical.codes)rŽr~csd|rt ||j¡}nt||jd}|sP|jjdk    rPt|jƒt|jjƒkrPtdƒ‚tƒ |j    |¡dS)aä
        Sets new categories inplace
 
        Parameters
        ----------
        fastpath : bool, default False
           Don't perform validation of the categories for uniqueness or nulls
 
        Examples
        --------
        >>> c = pd.Categorical(['a', 'b'])
        >>> c
        ['a', 'b']
        Categories (2, object): ['a', 'b']
 
        >>> c._set_categories(pd.Index(['a', 'c']))
        >>> c
        ['a', 'c']
        Categories (2, object): ['a', 'c']
        rNzKnew categories need to have the same number of items as the old categories!)
r1Ú_from_fastpathr[rgr_rYrZršr›r¬)rkr_rŽÚ    new_dtyper§rurvÚ_set_categoriesñsÿ
þýÿzCategorical._set_categoriescCs$t|j|j|jƒ}t|ƒ||ddS)a+
        Internal method for directly updating the CategoricalDtype
 
        Parameters
        ----------
        dtype : CategoricalDtype
 
        Notes
        -----
        We don't do any validation here. It's assumed that the dtype is
        a (valid) instance of `CategoricalDtype`.
        TrÀ)rarbr_rf)rkrgrbrururvrµs zCategorical._set_dtype)Úvaluer~cCs*t|j|d}| ¡}t ||j|¡|S)zÇ
        Set the ordered attribute to the boolean value.
 
        Parameters
        ----------
        value : bool
           Set whether this categorical is ordered (True) or not (False).
        r)r1r_rUrr›r¬)rkrÑrÏr‡rururvÚ set_ordered&s    zCategorical.set_orderedcCs
| d¡S)zŠ
        Set the Categorical to be ordered.
 
        Returns
        -------
        Categorical
            Ordered Categorical.
        T©rÒr©rururvÚ
as_ordered4s    zCategorical.as_orderedcCs
| d¡S)zŽ
        Set the Categorical to be unordered.
 
        Returns
        -------
        Categorical
            Unordered Categorical.
        FrÓr©rururvÚ as_unordered?s    zCategorical.as_unordered)ÚrenamecCsŒ|dkr|jj}t||d}| ¡}|rh|jjdk    r`t|jƒt|jjƒkr`d|j|jt|jƒk<|j}nt|j|j|jƒ}t     
|||¡|S)a¯
        Set the categories to the specified new_categories.
 
        `new_categories` can include new categories (which will result in
        unused categories) or remove old categories (which results in values
        set to NaN). If `rename==True`, the categories will simple be renamed
        (less or more items than in old categories will result in values set to
        NaN or in unused categories respectively).
 
        This method can be used to perform more than one action of adding,
        removing, and reordering simultaneously and is therefore faster than
        performing the individual steps via the more specialised methods.
 
        On the other hand this methods does not do checks (e.g., whether the
        old categories are included in the new categories on a reorder), which
        can result in surprising changes, for example when using special string
        dtypes, which does not considers a S1 string equal to a single char
        python string.
 
        Parameters
        ----------
        new_categories : Index-like
           The categories in new order.
        ordered : bool, default False
           Whether or not the categorical is treated as a ordered categorical.
           If not given, do not change the ordered information.
        rename : bool, default False
           Whether or not the new_categories should be considered as a rename
           of the old categories or as reordered categories.
 
        Returns
        -------
        Categorical with reordered categories.
 
        Raises
        ------
        ValueError
            If new_categories does not validate as categories
 
        See Also
        --------
        rename_categories : Rename categories.
        reorder_categories : Reorder categories.
        add_categories : Add new categories.
        remove_categories : Remove the specified categories.
        remove_unused_categories : Remove categories which are not used.
        NrrV) rgr[r1rUr_rYrcrarbrr›)rkÚnew_categoriesr[rÖrÏr‡rbrururvÚset_categoriesJs"1 ÿÿzCategorical.set_categoriescsPtˆƒr‡fdd„|jDƒ‰ntˆƒr:‡fdd„|jDƒ‰| ¡}| ˆ¡|S)aÉ
        Rename categories.
 
        Parameters
        ----------
        new_categories : list-like, dict-like or callable
 
            New categories which will replace old categories.
 
            * list-like: all items must be unique and the number of items in
              the new categories must match the existing number of categories.
 
            * dict-like: specifies a mapping from
              old categories to new. Categories not contained in the mapping
              are passed through and extra categories in the mapping are
              ignored.
 
            * callable : a callable that is called on all items in the old
              categories and whose return values comprise the new categories.
 
        Returns
        -------
        Categorical
            Categorical with renamed categories.
 
        Raises
        ------
        ValueError
            If new categories are list-like and do not have the same number of
            items than the current categories or do not validate as categories
 
        See Also
        --------
        reorder_categories : Reorder categories.
        add_categories : Add new categories.
        remove_categories : Remove the specified categories.
        remove_unused_categories : Remove categories which are not used.
        set_categories : Set the categories to the specified ones.
 
        Examples
        --------
        >>> c = pd.Categorical(['a', 'a', 'b'])
        >>> c.rename_categories([0, 1])
        [0, 0, 1]
        Categories (2, int64): [0, 1]
 
        For dict-like ``new_categories``, extra keys are ignored and
        categories not in the dictionary are passed through
 
        >>> c.rename_categories({'a': 'A', 'c': 'C'})
        ['A', 'A', 'b']
        Categories (2, object): ['A', 'b']
 
        You may also provide a callable to create the new categories
 
        >>> c.rename_categories(lambda x: x.upper())
        ['A', 'A', 'B']
        Categories (2, object): ['A', 'B']
        csg|]}ˆ ||¡‘qSru)Úget©r€Úitem©r×rurvr•Ìsz1Categorical.rename_categories.<locals>.<listcomp>csg|] }ˆ|ƒ‘qSrururÚrÜrurvr•Ðs)r'r_ÚcallablerUrÐ)rkr×r‡rurÜrvÚrename_categoriesŽs=
ÿ
zCategorical.rename_categoriescCs6t|jƒt|ƒks |j |¡js(tdƒ‚|j||dS)a 
        Reorder categories as specified in new_categories.
 
        `new_categories` need to include all old categories and no new category
        items.
 
        Parameters
        ----------
        new_categories : Index-like
           The categories in new order.
        ordered : bool, optional
           Whether or not the categorical is treated as a ordered categorical.
           If not given, do not change the ordered information.
 
        Returns
        -------
        Categorical
            Categorical with reordered categories.
 
        Raises
        ------
        ValueError
            If the new categories do not contain all old category items or any
            new ones
 
        See Also
        --------
        rename_categories : Rename categories.
        add_categories : Add new categories.
        remove_categories : Remove the specified categories.
        remove_unused_categories : Remove categories which are not used.
        set_categories : Set the categories to the specified ones.
        z=items in new_categories are not the same as in old categoriesr)rYr_Ú
differenceÚemptyrZrØ)rkr×r[rururvÚreorder_categoriesÖs#ÿ þÿzCategorical.reorder_categoriescCsÌt|ƒs|g}t|ƒt|jjƒ@}t|ƒdkr<td|›ƒ‚t|dƒr„ddlm}t    |jjj|jgƒ}|t
|jjƒt
|ƒ|d}nt
|jjƒt
|ƒ}t ||j ƒ}|  ¡}t|j|jƒ}t |||¡|S)a¨
        Add new categories.
 
        `new_categories` will be included at the last/highest place in the
        categories and will be unused directly after this call.
 
        Parameters
        ----------
        new_categories : category or list-like of category
           The new categories to be included.
 
        Returns
        -------
        Categorical
            Categorical with new categories added.
 
        Raises
        ------
        ValueError
            If the new categories include old categories or do not validate as
            categories
 
        See Also
        --------
        rename_categories : Rename categories.
        reorder_categories : Reorder categories.
        remove_categories : Remove the specified categories.
        remove_unused_categories : Remove categories which are not used.
        set_categories : Set the categories to the specified ones.
 
        Examples
        --------
        >>> c = pd.Categorical(['c', 'b', 'c'])
        >>> c
        ['c', 'b', 'c']
        Categories (2, object): ['b', 'c']
 
        >>> c.add_categories(['d', 'a'])
        ['c', 'b', 'c']
        Categories (4, object): ['b', 'c', 'd', 'a']
        rz0new categories must not include old categories: rg©rKr)r,Úsetrgr_rYrZÚhasattrrÁrKr rr1r[rUrr¬rr›)rkr×Zalready_includedrKrgrÏr‡rbrururvÚadd_categoriess,+ ÿ
 ÿÿ zCategorical.add_categoriescCszddlm}t|ƒs|g}||ƒ ¡ ¡}|jj |¡}| |jj¡}t|ƒdkrht    |ƒ}t
d|›ƒ‚|j ||j ddS)a‘
        Remove the specified categories.
 
        `removals` must be included in the old categories. Values which were in
        the removed categories will be set to NaN
 
        Parameters
        ----------
        removals : category or list of categories
           The categories which should be removed.
 
        Returns
        -------
        Categorical
            Categorical with removed categories.
 
        Raises
        ------
        ValueError
            If the removals are not contained in the categories
 
        See Also
        --------
        rename_categories : Rename categories.
        reorder_categories : Reorder categories.
        add_categories : Add new categories.
        remove_unused_categories : Remove categories which are not used.
        set_categories : Set the categories to the specified ones.
 
        Examples
        --------
        >>> c = pd.Categorical(['a', 'c', 'b', 'c', 'd'])
        >>> c
        ['a', 'c', 'b', 'c', 'd']
        Categories (4, object): ['a', 'b', 'c', 'd']
 
        >>> c.remove_categories(['d', 'a'])
        [NaN, 'c', 'b', 'c', NaN]
        Categories (2, object): ['b', 'c']
        r©rJz(removals must all be in old categories: F)r[rÖ) rÁrJr,ÚuniqueÚdropnargr_rßrYrãrZrØr[)rkÚremovalsrJr×Z not_includedrururvÚremove_categoriesFs)  zCategorical.remove_categoriescCs„tj|jdd\}}|jdkr@|ddkr@|dd…|d}}|jj |¡}tj||j    d}t
||jƒ}|  ¡}t   |||¡|S)a¡
        Remove categories which are not used.
 
        Returns
        -------
        Categorical
            Categorical with unused categories dropped.
 
        See Also
        --------
        rename_categories : Rename categories.
        reorder_categories : Reorder categories.
        add_categories : Add new categories.
        remove_categories : Remove the specified categories.
        set_categories : Set the categories to the specified ones.
 
        Examples
        --------
        >>> c = pd.Categorical(['a', 'c', 'b', 'c', 'd'])
        >>> c
        ['a', 'c', 'b', 'c', 'd']
        Categories (4, object): ['a', 'b', 'c', 'd']
 
        >>> c[2] = 'a'
        >>> c[4] = 'c'
        >>> c
        ['a', 'c', 'a', 'c', 'c']
        Categories (4, object): ['a', 'b', 'c', 'd']
 
        >>> c.remove_unused_categories()
        ['a', 'c', 'a', 'c', 'c']
        Categories (2, object): ['a', 'c']
        T)Zreturn_inverserrVr‘Nr)rirçrcÚsizergr_Útaker1rÎr[rrUrr›)rkr’Úinvr×rÏÚ    new_codesr‡rururvÚremove_unused_categories~s"ÿ z$Categorical.remove_unused_categoriescCsp|j |¡}z|j|j ¡||jdWStk
rjt |jdk¡rX|     t
|ƒtj ¡}t  ||j¡YSXdS)a‡    
        Map categories using an input mapping or function.
 
        Maps the categories to new categories. If the mapping correspondence is
        one-to-one the result is a :class:`~pandas.Categorical` which has the
        same order property as the original, otherwise a :class:`~pandas.Index`
        is returned. NaN values are unaffected.
 
        If a `dict` or :class:`~pandas.Series` is used any unmapped category is
        mapped to `NaN`. Note that if this happens an :class:`~pandas.Index`
        will be returned.
 
        Parameters
        ----------
        mapper : function, dict, or Series
            Mapping correspondence.
 
        Returns
        -------
        pandas.Categorical or pandas.Index
            Mapped categorical.
 
        See Also
        --------
        CategoricalIndex.map : Apply a mapping correspondence on a
            :class:`~pandas.CategoricalIndex`.
        Index.map : Apply a mapping correspondence on an
            :class:`~pandas.Index`.
        Series.map : Apply a mapping correspondence on a
            :class:`~pandas.Series`.
        Series.apply : Apply more complex functions on a
            :class:`~pandas.Series`.
 
        Examples
        --------
        >>> cat = pd.Categorical(['a', 'b', 'c'])
        >>> cat
        ['a', 'b', 'c']
        Categories (3, object): ['a', 'b', 'c']
        >>> cat.map(lambda x: x.upper())
        ['A', 'B', 'C']
        Categories (3, object): ['A', 'B', 'C']
        >>> cat.map({'a': 'first', 'b': 'second', 'c': 'third'})
        ['first', 'second', 'third']
        Categories (3, object): ['first', 'second', 'third']
 
        If the mapping is one-to-one the ordering of the categories is
        preserved:
 
        >>> cat = pd.Categorical(['a', 'b', 'c'], ordered=True)
        >>> cat
        ['a', 'b', 'c']
        Categories (3, object): ['a' < 'b' < 'c']
        >>> cat.map({'a': 3, 'b': 2, 'c': 1})
        [3, 2, 1]
        Categories (3, int64): [3 < 2 < 1]
 
        If the mapping is not one-to-one an :class:`~pandas.Index` is returned:
 
        >>> cat.map({'a': 'first', 'b': 'second', 'c': 'first'})
        Index(['first', 'second', 'first'], dtype='object')
 
        If a `dict` is used, all unmapped categories are mapped to `NaN` and
        the result is an :class:`~pandas.Index`:
 
        >>> cat.map({'a': 'first', 'b': 'second'})
        Index(['first', 'second', nan], dtype='object')
        )r_r[rVN) r_ÚmaprÊrcrUr[rZrirdÚinsertrYÚnanrì)rkZmapperr×rururvrð±sE ÿzCategorical.mapcCs t|ƒs| |¡S| |¡SdSr)r*Ú_validate_listlikeÚ_validate_scalar)rkrÑrururvÚ_validate_setitem_value s
z#Categorical._validate_setitem_valuecCs@t||jjƒrd}n(||jkr*| |¡}ntd|›dƒd‚|S)aK
        Convert a user-facing fill_value to a representation to use with our
        underlying ndarray, raising TypeError if this is not possible.
 
        Parameters
        ----------
        fill_value : object
 
        Returns
        -------
        fill_value : int
 
        Raises
        ------
        TypeError
        rVz5Cannot setitem on a Categorical with a new category (z), set the categories firstN)r5r_rgrer\)rkrrrururvrôs
 
ÿýzCategorical._validate_scalarzNpDtype | NonecCs8t|jj|jƒ}|r.t||jjƒs.t ||¡St |¡S)zÿ
        The numpy array interface.
 
        Returns
        -------
        numpy.array
            A numpy array of either the specified dtype or,
            if dtype==None (default), the same dtype as
            categorical.categories.dtype.
        )r=r_r¶rcr(rgrirÇ)rkrgrnrururvÚ    __array__2s  zCategorical.__array__znp.ufuncÚstr)ÚufuncÚmethodcOs†tj|||f|ž|Ž}|tk    r"|Sd|kr@tj|||f|ž|ŽS|dkrjtj|||f|ž|Ž}|tk    rj|Std|j›d|j›ƒ‚dS)NÚoutÚreducezObject with dtype z cannot perform the numpy op )    r9Z!maybe_dispatch_ufunc_to_dunder_opÚNotImplementedr8Zdispatch_ufunc_with_outZdispatch_reduction_ufuncr\rgrx)rkrørùÚinputsÚkwargsr·rururvÚ__array_ufunc__FsHÿÿÿÿÿÿÿÿÿÿzCategorical.__array_ufunc__csbt|tƒstƒ |¡Sd|kr4t|d|dƒ|d<d|krRd|krR| d¡|d<tƒ |¡dS)z*Necessary for making this object picklablerŒZ _categoriesZ_orderedrcr¬N)r]ÚdictršÚ __setstate__r1Úpop)rkÚstater§rurvrcs
 zCategorical.__setstate__cCs|jj|jjjjSr)rcÚnbytesrgr_r”r©rururvrqszCategorical.nbytes)Údeepr~cCs|jj|jjj|dS)aè
        Memory usage of my values
 
        Parameters
        ----------
        deep : bool
            Introspect the data deeply, interrogate
            `object` dtypes for system-level memory consumption
 
        Returns
        -------
        bytes used
 
        Notes
        -----
        Memory usage does not include memory consumed by elements that
        are not components of the array if deep=False
 
        See Also
        --------
        numpy.ndarray.nbytes
        )r)rcrrgr_Ú memory_usage)rkrrururvruszCategorical.memory_usagecCs
|jdkS)aX
        Detect missing values
 
        Missing values (-1 in .codes) are detected.
 
        Returns
        -------
        np.ndarray[bool] of whether my values are null
 
        See Also
        --------
        isna : Top-level isna.
        isnull : Alias of isna.
        Categorical.notna : Boolean inverse of Categorical.isna.
 
        rV)rcr©rururvr6ŽszCategorical.isnacCs
| ¡S)a„
        Inverse of isna
 
        Both missing values (-1 in .codes) and NA as a category are detected as
        null.
 
        Returns
        -------
        np.ndarray[bool] of whether my values are not null
 
        See Also
        --------
        notna : Top-level notna.
        notnull : Alias of notna.
        Categorical.isna : Boolean inverse of Categorical.notna.
 
        )r6r©rururvÚnotna£szCategorical.notnarK)rèr~c Cs¾ddlm}m}|j|j}}t|ƒ|dk}}t |¡| ¡}}    |sL|    rp|    rT|n||}
tj    |
|phdd} n t     t 
|||¡¡} t  |d¡}t ||j jƒ}| |¡}|| ||ƒddddS)    a{
        Return a Series containing counts of each category.
 
        Every category will have an entry, even those with a count of 0.
 
        Parameters
        ----------
        dropna : bool, default True
            Don't include counts of NaN.
 
        Returns
        -------
        counts : Series
 
        See Also
        --------
        Series.value_counts
        r)ÚCategoricalIndexrK)Z    minlengthrVrÆÚcountF)ÚindexrgÚnamerU)rÁrrKrcr_rYriÚarangeÚallZbincountr¡ÚappendrrgÚ_from_backing_data) rkrèrrKÚcoder‡ZncatroÚixÚcleanZobsr    rururvÚ value_counts¹s$ 
ÿzCategorical.value_countsztype_t[Categorical]r)r¯r£rgr~cCs*|jg|d}tj||jjd}| |¡S)zž
        Analogous to np.empty(shape, dtype=dtype)
 
        Parameters
        ----------
        shape : tuple[int]
        dtype : CategoricalDtype
        r)r°riÚzerosr¬rgr)r¯r£rgr¥ZbackingrururvÚ_emptyæs zCategorical._emptycCsVt|jjƒr|jj|jtdSt|jƒrLd|jkrL|j d¡j|jtj    dSt 
|¡S)a
        Return the values.
 
        For internal compatibility with pandas formatting.
 
        Returns
        -------
        np.ndarray or Index
            A numpy array of the same dtype as categorical.categories.dtype or
            Index if datetime / periods.
        r´rVr–) r/r_rgrìrcrr+r³riròrjr©rururvÚ_internal_get_valuesûs
z Categorical._internal_get_valuescCs|jstd|›dƒ‚dS)zassert that we are orderedz)Categorical is not ordered for operation zG
you can use .as_ordered() to change the Categorical to an ordered one
N)r[r\)rkrsrururvÚcheck_for_ordereds
ÿzCategorical.check_for_orderedZ    quicksort©Ú    ascendingÚkindrc stƒjf||dœ|—ŽS)a¡
        Return the indices that would sort the Categorical.
 
        Missing values are sorted at the end.
 
        Parameters
        ----------
        ascending : bool, default True
            Whether the indices should result in an ascending
            or descending sort.
        kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional
            Sorting algorithm.
        **kwargs:
            passed through to :func:`numpy.argsort`.
 
        Returns
        -------
        np.ndarray[np.intp]
 
        See Also
        --------
        numpy.ndarray.argsort
 
        Notes
        -----
        While an ordering is applied to the category values, arg-sorting
        in this context refers more to organizing and grouping together
        based on matching category values. Thus, this function can be
        called on an unordered Categorical instance unlike the functions
        'Categorical.min' and 'Categorical.max'.
 
        Examples
        --------
        >>> pd.Categorical(['b', 'b', 'a', 'c']).argsort()
        array([2, 0, 1, 3])
 
        >>> cat = pd.Categorical(['b', 'b', 'a', 'c'],
        ...                      categories=['c', 'b', 'a'],
        ...                      ordered=True)
        >>> cat.argsort()
        array([3, 0, 1, 2])
 
        Missing values are placed at the end
 
        >>> cat = pd.Categorical([2, None, 1])
        >>> cat.argsort()
        array([2, 0, 1])
        r)ršÚargsort)rkrrrþr§rurvrs3zCategorical.argsort)ÚinplacerÚ na_positionzLiteral[False])rrrr~cCsdSrru©rkrrrrururvrÃLszCategorical.sort_values©rrz Literal[True]cCsdSrrurrururvrÃVsÚlastzCategorical | NonecCsbt|dƒ}|dkr$tdt|ƒ›ƒ‚t|||d}|sJ|j|}| |¡S|j||jdd…<dS)a†
        Sort the Categorical by category value returning a new
        Categorical by default.
 
        While an ordering is applied to the category values, sorting in this
        context refers more to organizing and grouping together based on
        matching category values. Thus, this function can be called on an
        unordered Categorical instance unlike the functions 'Categorical.min'
        and 'Categorical.max'.
 
        Parameters
        ----------
        inplace : bool, default False
            Do operation in place.
        ascending : bool, default True
            Order ascending. Passing False orders descending. The
            ordering parameter provides the method by which the
            category values are organized.
        na_position : {'first', 'last'} (optional, default='last')
            'first' puts NaNs at the beginning
            'last' puts NaNs at the end
 
        Returns
        -------
        Categorical or None
 
        See Also
        --------
        Categorical.sort
        Series.sort_values
 
        Examples
        --------
        >>> c = pd.Categorical([1, 2, 2, 1, 5])
        >>> c
        [1, 2, 2, 1, 5]
        Categories (3, int64): [1, 2, 5]
        >>> c.sort_values()
        [1, 1, 2, 2, 5]
        Categories (3, int64): [1, 2, 5]
        >>> c.sort_values(ascending=False)
        [5, 2, 2, 1, 1]
        Categories (3, int64): [1, 2, 5]
 
        >>> c = pd.Categorical([1, 2, 2, 1, 5])
 
        'sort_values' behaviour with NaNs. Note that 'na_position'
        is independent of the 'ascending' parameter:
 
        >>> c = pd.Categorical([np.nan, 2, 2, np.nan, 5])
        >>> c
        [NaN, 2, 2, NaN, 5]
        Categories (2, int64): [2, 5]
        >>> c.sort_values()
        [2, 2, 5, NaN, NaN]
        Categories (2, int64): [2, 5]
        >>> c.sort_values(ascending=False)
        [5, 2, 2, NaN, NaN]
        Categories (2, int64): [2, 5]
        >>> c.sort_values(na_position='first')
        [NaN, NaN, 2, 2, 5]
        Categories (2, int64): [2, 5]
        >>> c.sort_values(ascending=False, na_position='first')
        [NaN, NaN, 5, 2, 2]
        Categories (2, int64): [2, 5]
        r)r Úfirstzinvalid na_position: rN)rrZÚreprrFrcr)rkrrrZ
sorted_idxrbrururvrÃ\sI
 
 
rZaverageÚkeep©ÚaxisrùÚ    na_optionrÚpctrcCs*|dkr t‚| ¡}tj||||||dS)z*
        See Series.rank.__doc__.
        rr$)r Ú_values_for_rankr7Úrank)rkr%rùr&rr'ZvffrururvÚ_rank±s úzCategorical._rankcCsxddlm}|jr>|j}|dk}| ¡rt| d¡}tj||<n6t|j    ƒrTt 
|¡}n t 
|  ||j    dd  ¡j ¡¡}|S)zð
        For correctly ranking ordered categorical data. See GH#15420
 
        Ordered categorical data should be ranked on the basis of
        codes with -1 translated to NaN.
 
        Returns
        -------
        numpy.array
 
        rrârVÚfloat64FrT)rÁrKr[rbrdr³riròr#r_rjrÞr)r”)rkrKr”rorururvr(És 
 
 ÿÿzCategorical._values_for_rankcCs|jSr)r¬r©rururvrcìszCategorical._codes)rpcCs|dkrtjS|j|Sr«)riÚNaNr_)rkrprururvÚ    _box_funcðszCategorical._box_funccCs|j |¡}|jj |¡}|Sr)r_r…r¬rgrf)rkrˆrrururvreõs zCategorical._unbox_scalarrcs8ˆjdkrtˆ ¡ ¡ƒS‡fdd„ttˆƒƒDƒSdS)zJ
        Returns an Iterator over the values of this Categorical.
        r‘c3s|]}ˆ|VqdSrru)r€Únr©rurvrƒsz'Categorical.__iter__.<locals>.<genexpr>N)rŸÚiterrr‹ÚrangerYr©rur©rvÚ__iter__þs
zCategorical.__iter__cCs.t||jjƒrt| ¡ ¡ƒSt|||jdS)z?
        Returns True if `key` is in this Categorical.
        r)r5r_rgr|r6rdrŠrc)rkrˆrururvÚ __contains__szCategorical.__contains__)ÚboxedcCsdSrru)rkr3rururvÚ
_formatterszCategorical._formatteré
)Úmax_valsÚfooterr~cCsv|d}|d|…jddd}||| d…jddd}|dd…›d|dd…›}|rn|›d| ¡›}t|ƒS)    zd
        a short repr displaying only max_vals and an optional (but default
        footer)
        éNF©Úlengthr7rVz, ..., r‘Ú
)Ú    _get_reprÚ _repr_footerr÷)rkr6r7ÚnumÚheadÚtailr·rururvÚ
_tidy_reprszCategorical._tidy_reprz    list[str]cCsœtdƒdkrdntdƒ}ddlm}t|jdtd}t|jƒ|kr€|d}||jd|…ƒ}||j| d…ƒ}|dg|}n
||jƒ}d    d
„|Dƒ}|S) z9
        return the base repr for the categories
        zdisplay.max_categoriesrr5©ÚformatN)Ú    formatterÚquotingr8z...cSsg|] }| ¡‘qSru)Ústrip©r€Úxrururvr•>sz0Categorical._repr_categories.<locals>.<listcomp>)rÚpandas.io.formatsrCrÚ format_arrayrrYr_)rkZmax_categoriesÚfmtrJr>r?r@Ú category_strsrururvÚ_repr_categories's$
ÿý ÿ
zCategorical._repr_categoriescCs| ¡}t|jjƒ}dt|jƒ›d|›d}tƒ\}}tdƒp@|}t ¡rNd}d}d}t|ƒ}    |j    rhdnd    \}
} |  
¡›d
} |D]j} |dkrÈ|    |
t| ƒ|krÈ|| d t|ƒd 7}t|ƒd }    n|sà|| 7}|    t| ƒ7}    || 7}d }q‚|›d|  dd¡›dS)z@
        Returns a string representation of the footer.
        z Categories (ú, z): z display.widthrÚT)éz < )r8rNr;ú r‘Fú[z     < ... < z ... ú]) rMr÷r_rgrYrrrHZin_ipython_frontendr[ÚrstripÚreplace)rkrLrgZ    levheaderÚwidthÚheightÚ    max_widthZ    levstringÚstartZ cur_col_lenZsep_lenÚsepÚlinesepÚvalrururvÚ_repr_categories_infoAs, 
  z!Categorical._repr_categories_infocCs| ¡}dt|ƒ›d|›S)NzLength: r;)r]rY)rkÚinforururvr=^szCategorical._repr_footerr,)r:Úna_repr7r~cCs.ddlm}|j||||d}| ¡}t|ƒS)NrrB)r:r_r7)rIrCZCategoricalFormatterZ    to_stringr÷)rkr:r_r7rKrDr·rururvr<bs ÿzCategorical._get_reprcCsfd}t|jƒ|kr| |¡}nDt|jƒdkrB|jt|ƒ|kd}n |jddd dd¡}d    |›}|S)
z(
        String representation.
        r5r)r:FTr9r;rNz[], )rYrcrAr<rU)rkÚ_maxlenr·rmrururvÚ__repr__ms 
zCategorical.__repr__cCs˜t|dd}t|tƒr<t|j|jƒs,tdƒ‚| |¡}|jSddlm    }|j
|dd  |j ¡}t |ƒrzt|ƒ ¡sztdƒ‚|j  |¡}|j|jjdd    S)
NT)Z extract_numpyzCCannot set a Categorical with another, without identical categoriesrræF)Z tupleize_colszMCannot setitem on a Categorical with a new category, set the categories firstrT)rCr]rMr(rgr\Ú_encode_with_my_categoriesrcrÁrJZ _with_inferrßr_rYr6r Ú get_indexerr³r¬)rkrÑrJZto_addrbrururvró~s$ 
ÿ
 ÿÿ zCategorical._validate_listlikez$dict[Hashable, npt.NDArray[np.intp]]csX|j}t t|jƒ|j¡\‰}t|ƒ ¡}‡fdd„t||dd…ƒDƒ}t    t||ƒƒS)a§
        Compute the inverse of a categorical, returning
        a dict of categories -> indexers.
 
        *This is an internal function*
 
        Returns
        -------
        Dict[Hashable, np.ndarray[np.intp]]
            dict of categories -> indexers
 
        Examples
        --------
        >>> c = pd.Categorical(list('aabca'))
        >>> c
        ['a', 'a', 'b', 'c', 'a']
        Categories (3, object): ['a', 'b', 'c']
        >>> c.categories
        Index(['a', 'b', 'c'], dtype='object')
        >>> c.codes
        array([0, 0, 1, 2, 0], dtype=int8)
        >>> c._reverse_indexer()
        {'a': array([0, 1, 4]), 'b': array([2]), 'c': array([3])}
 
        c3s|]\}}ˆ||…VqdSrru)r€rYÚend©Úrrurvrƒ¾sz/Categorical._reverse_indexer.<locals>.<genexpr>r‘N)
r_ÚlibalgosZgroupsort_indexerr"rbrër!ZcumsumÚzipr)rkr_ÚcountsZ_resultrurervÚ_reverse_indexerŸsÿ  zCategorical._reverse_indexer)ÚskipnacKs†t | dd¡¡t d|¡| d¡t|jƒs:|jjS|jdk}|     ¡sp|rh| 
¡rh|j|  ¡}qzt j Sn
|j  ¡}| d|¡S)a/
        The minimum value of the object.
 
        Only ordered `Categoricals` have a minimum!
 
        Raises
        ------
        TypeError
            If the `Categorical` is not `ordered`.
 
        Returns
        -------
        min : the minimum of this `Categorical`, NA value if empty
        r%rrurÉrVN)ÚnvÚvalidate_minmax_axisrÙZ validate_minrrYrcrgÚna_valuer rdrÉriròÚ_wrap_reduction_result©rkrkrþZgoodÚpointerrururvrÉÄs 
 
 
 
zCategorical.mincKs†t | dd¡¡t d|¡| d¡t|jƒs:|jjS|jdk}|     ¡sp|rh| 
¡rh|j|  ¡}qzt j Sn
|j  ¡}| d|¡S)a2
        The maximum value of the object.
 
        Only ordered `Categoricals` have a maximum!
 
        Raises
        ------
        TypeError
            If the `Categorical` is not `ordered`.
 
        Returns
        -------
        max : the maximum of this `Categorical`, NA if array is empty
        r%rrurÈrVN)rlrmrÙZ validate_maxrrYrcrgrnr rdrÈriròrorprururvrÈäs 
 
 
 
zCategorical.maxcCsN|j}d}|r| ¡}tj||d}ttj|ƒ}|j|jks@t‚|     |¡}|S)N)ro)
rcr6r7Úmoder riržrgÚAssertionErrorr)rkrèrbroZ    res_codesÚresrururvÚ_modes 
zCategorical._modecs
tƒ ¡S)aß
        Return the ``Categorical`` which ``categories`` and ``codes`` are
        unique.
 
        .. versionchanged:: 1.3.0
 
            Previously, unused categories were dropped from the new categories.
 
        Returns
        -------
        Categorical
 
        See Also
        --------
        pandas.unique
        CategoricalIndex.unique
        Series.unique : Return unique values of Series object.
 
        Examples
        --------
        >>> pd.Categorical(list("baabc")).unique()
        ['b', 'a', 'c']
        Categories (3, object): ['a', 'b', 'c']
        >>> pd.Categorical(list("baab"), categories=list("abc"), ordered=True).unique()
        ['b', 'a']
        Categories (3, object): ['a' < 'b' < 'c']
        )ršrçr©r§rurvrçszCategorical.unique)Ú
res_valuesr~cCs|j|jjkst‚|Sr)rgr¬rs)rkrvrururvÚ_cast_quantile_result2sz!Categorical._cast_quantile_resultr–)rlr~cCs6t|tƒsdS| |¡r2| |¡}t |j|j¡SdS)z²
        Returns True if categorical arrays are equal.
 
        Parameters
        ----------
        other : `Categorical`
 
        Returns
        -------
        bool
        F)r]rMr^rbriZ array_equalrc©rkrlrururvr`7s
 
 
zCategorical.equalsztype[CategoricalT]zSequence[CategoricalT]rL)r¯Ú    to_concatr%r~cs´ddlm}|d}||jkr4td|›d|j›ƒ‚|dkr¨tdd„|DƒƒsRt‚g}|D]&‰| ‡fdd    „tˆjdƒDƒ¡qZ|j|dd
}|j    t
|ƒd d d }|S||ƒ}|S)Nr)Úunion_categoricalszaxis z) is out of bounds for array of dimension r‘css|]}|jdkVqdS)r8N)rŸrGrururvrƒXsz0Categorical._concat_same_type.<locals>.<genexpr>csg|]}ˆdd…|f‘qSrru)r€rp©Úobjrurvr•^sz1Categorical._concat_same_type.<locals>.<listcomp>©r%rVÚF)Úorder) Zpandas.core.dtypes.concatrzrŸrZr Úextendr0r£Ú_concat_same_typeÚreshaperY)r¯ryr%rzr!Ztc_flatZres_flatr·rur{rvrJs" 
ÿ$zCategorical._concat_same_typecCs t|j|j|jdd}| |¡S)z×
        Re-encode another categorical using this Categorical's categories.
 
        Notes
        -----
        This assumes we have already checked
        self._categories_match_up_to_permutation(other).
        FrT)rarbr_r)rkrlrbrururvrbjs ÿz&Categorical._encode_with_my_categoriescCst|jƒt|jƒkS)zÞ
        Returns True if categoricals are the same dtype
          same categories, and same ordered
 
        Parameters
        ----------
        other : Categorical
 
        Returns
        -------
        bool
        )r„rgrxrururvr^{s z/Categorical._categories_match_up_to_permutationrIcCsZ|jdd}|| ¡}ddlm}ddlm}|||gdd}|dd    gƒ|_d
|j_|S) z­
        Describes this Categorical
 
        Returns
        -------
        description: `DataFrame`
            A dataframe with frequency and counts by category.
        F)rèrræ)Úconcatr‘r}riÚfreqsr_)    rÚsumrÁrJZpandas.core.reshape.concatrƒÚcolumnsr
r )rkrir„rJrƒr·rururvÚdescribeŠs        zCategorical.describeznpt.NDArray[np.bool_]cCsft|ƒs"t|ƒj}td|›dƒ‚t|ddƒ}t t|ƒ¡}|j     |¡}|||dkB}t
  |j |¡S)a¡
        Check whether `values` are contained in Categorical.
 
        Return a boolean NumPy Array showing whether each element in
        the Categorical matches an element in the passed sequence of
        `values` exactly.
 
        Parameters
        ----------
        values : set or list-like
            The sequence of values to test. Passing in a single string will
            raise a ``TypeError``. Instead, turn a single string into a
            list of one element.
 
        Returns
        -------
        np.ndarray[bool]
 
        Raises
        ------
        TypeError
          * If `values` is not a set or list-like
 
        See Also
        --------
        pandas.Series.isin : Equivalent method on Series.
 
        Examples
        --------
        >>> s = pd.Categorical(['lama', 'cow', 'lama', 'beetle', 'lama',
        ...                'hippo'])
        >>> s.isin(['cow', 'lama'])
        array([ True,  True,  True, False,  True, False])
 
        Passing a single string as ``s.isin('lama')`` will raise an error. Use
        a list of one element instead:
 
        >>> s.isin(['lama'])
        array([ True, False,  True, False,  True, False])
        zIonly list-like objects are allowed to be passed to isin(), you passed a [rSNr) r,rfrxr\rDrirÇr6r_rcr7rÂrb)rkr”Z values_typer¤Z code_valuesrururvrŸs)
 
ÿ  zCategorical.isin)rcCs(ddlm}t|dƒ}|r|n| ¡}tt |¡ƒ}| ¡rxt |¡|}|j|j     |¡}| 
|¡}t   ||j |j¡|j ¡}    |    j||d}    ||    ƒ}
|j |
¡} t t|    ƒ¡} t | dk| | ¡} |  ¡} |     | ¡} | jdd} || ƒ} t|j|
| dd    }t| |jjd
}t   |||¡|s$|SdS) Nrrær)Ú
to_replacerÑrVr!)r#FrTr)rÁrJrrUr6rirÇrdr_rÂrêrr›rbrgZ    to_seriesrUÚget_indexer_forr rYr¡rrìZdrop_duplicatesrarcr1r[)rkrˆrÑrrJr‡roréZnew_catZserZ
all_valuesZidxrZlocsr×rîrÏrururvÚ_replaceÔs: 
 
 
 
 ÿzCategorical._replace)Úconvertc    Cs<ddlm}|j}|j}|| ¡ƒ |||¡}t|||dS)Nr©Ú PandasArrayr´)Úpandas.core.arraysrr_rbrÅÚ_str_mapr=)    rkÚfrnrgr‹rr_rbr·rururvrús
 zCategorical._str_mapú|)rZcCs ddlm}|| t¡ƒ |¡S)NrrŒ)rŽrr³r÷Ú_str_get_dummies)rkrZrrururvr’    s zCategorical._str_get_dummies)NNNFT).).).)T)N)NNN)F)NF)N)N)F)T)F)r5T)Tr,T)T)r)r‘)erxÚ
__module__Ú __qualname__Ú__doc__Z__array_priority__rBZ _hidden_attrsÚ    frozensetZ_typÚ__annotations__r›Úpropertyrgr­Ú classmethodr°r r³r¸rÄrÊr_r[rbrÐrµrÒrÔrÕrØrÞrárårêrïrðr{ryÚeqrWrzrXÚltrPÚgtrQÚlerRÚgerSrõrôr?rörÿrrrr6ZisnullrZnotnullrrrrrrÃr*r(rcr-rer1r2r4rArMr]r=r<rarórjrÉrÈrurçrwr`rrbr^r‡rÂrŠriròrr’Ú __classcell__rurur§rvrMös
iùdÿ=ÿ DÿE%  DH
+E83Q
 
 
 
 
 
-
ÿ5û    ÿûXù#         ÿ !%   ÿ5'ÿ r_r[r˜)ZdelegateZ    accessorsÚtyprÞrárårêrïrØrÔrÕrùc@sTeZdZdZddœdd„Zedd„ƒZdd    „Zd
d „Ze    d dœd d„ƒZ
dd„Z dS)ÚCategoricalAccessoraP
    Accessor object for categorical properties of the Series values.
 
    Parameters
    ----------
    data : Series or CategoricalIndex
 
    Examples
    --------
    >>> s = pd.Series(list("abbccc")).astype("category")
    >>> s
    0    a
    1    b
    2    b
    3    c
    4    c
    5    c
    dtype: category
    Categories (3, object): ['a', 'b', 'c']
 
    >>> s.cat.categories
    Index(['a', 'b', 'c'], dtype='object')
 
    >>> s.cat.rename_categories(list("cba"))
    0    c
    1    b
    2    b
    3    a
    4    a
    5    a
    dtype: category
    Categories (3, object): ['c', 'b', 'a']
 
    >>> s.cat.reorder_categories(list("cba"))
    0    a
    1    b
    2    b
    3    c
    4    c
    5    c
    dtype: category
    Categories (3, object): ['c', 'b', 'a']
 
    >>> s.cat.add_categories(["d", "e"])
    0    a
    1    b
    2    b
    3    c
    4    c
    5    c
    dtype: category
    Categories (5, object): ['a', 'b', 'c', 'd', 'e']
 
    >>> s.cat.remove_categories(["a", "c"])
    0    NaN
    1      b
    2      b
    3    NaN
    4    NaN
    5    NaN
    dtype: category
    Categories (1, object): ['b']
 
    >>> s1 = s.cat.add_categories(["d", "e"])
    >>> s1.cat.remove_unused_categories()
    0    a
    1    b
    2    b
    3    c
    4    c
    5    c
    dtype: category
    Categories (3, object): ['a', 'b', 'c']
 
    >>> s.cat.set_categories(list("abcde"))
    0    a
    1    b
    2    b
    3    c
    4    c
    5    c
    dtype: category
    Categories (5, object): ['a', 'b', 'c', 'd', 'e']
 
    >>> s.cat.as_ordered()
    0    a
    1    b
    2    b
    3    c
    4    c
    5    c
    dtype: category
    Categories (3, object): ['a' < 'b' < 'c']
 
    >>> s.cat.as_unordered()
    0    a
    1    b
    2    b
    3    c
    4    c
    5    c
    dtype: category
    Categories (3, object): ['a', 'b', 'c']
    rr}cCs.| |¡|j|_|j|_|j|_| ¡dSr)Ú    _validater”Ú_parentr
Ú_indexr Ú_nameZ_freeze)rkÚdatarururvr›Œ    s
 
zCategoricalAccessor.__init__cCst|jƒstdƒ‚dS)Nz2Can only use .cat accessor with a 'category' dtype)r%rgÚAttributeError)r¦rururvr¢“    s
zCategoricalAccessor._validatecCs t|j|ƒSr)rhr£)rkr rururvÚ_delegate_property_get˜    sz*CategoricalAccessor._delegate_property_getcCst|j||ƒSr)Úsetattrr£)rkr Z
new_valuesrururvÚ_delegate_property_set›    sz*CategoricalAccessor._delegate_property_setrKcCsddlm}||jj|jdS)z>
        Return Series of codes as well as the index.
        rrâ)r
)rÁrKr£rbr¤)rkrKrururvrbž    s zCategoricalAccessor.codescOs@ddlm}t|j|ƒ}|||Ž}|dk    r<|||j|jdSdS)Nrrâ)r
r )rÁrKrhr£r¤r¥)rkr ÚargsrþrKrùrtrururvÚ_delegate_method§    s
 
z$CategoricalAccessor._delegate_methodN) rxr“r”r•r›Ú staticmethodr¢r¨rªr˜rbr¬rurururvr¡    si
r¡rJr±)r_r~cCs<|jdkr(| ¡}t||ƒ}| |j¡S| |¡}t||ƒS)z¤
    utility routine to turn values into codes given the specified categories
 
    If `values` is known to be a Categorical, use recode_for_categories instead.
    r‘)rŸZravelr¢r‚r£r‰r)r”r_Zflatrbrururvr¢³    s 
 
 
r¢T)rbrUr~cCsXt|ƒdkr|r| ¡S|S| |¡r6|r2| ¡S|St| |¡|ƒ}t||dd}|S)a#
    Convert a set of codes for to a new set of categories
 
    Parameters
    ----------
    codes : np.ndarray
    old_categories, new_categories : Index
    copy: bool, default True
        Whether to copy if the codes are unchanged.
 
    Returns
    -------
    new_codes : np.ndarray[np.int64]
 
    Examples
    --------
    >>> old_cat = pd.Index(['b', 'a', 'c'])
    >>> new_cat = pd.Index(['a', 'b'])
    >>> codes = np.array([0, 1, 1, 2])
    >>> recode_for_categories(codes, old_cat, new_cat)
    array([ 1,  0,  0, -1], dtype=int8)
    rrVr´)rYrUr`rrcr=)rbZold_categoriesr×rUZindexerrîrururvra    s 
ÿraztuple[np.ndarray, Index]cCs„ddlm}t|ƒstdƒ‚t|ƒrdt|ƒ}tjt|j    ƒ|j
j d}t j ||j d}||ƒ}|j
}nt |dd}|j    }|j
}||fS)az
    Factorize an input `values` into `categories` and `codes`. Preserves
    categorical dtype in `categories`.
 
    Parameters
    ----------
    values : list-like
 
    Returns
    -------
    codes : ndarray
    categories : Index
        If `values` has a categorical dtype, then `categories` is
        a CategoricalIndex keeping the categories and order of `values`.
    r)rzInput must be list-likerFr)rÁrr,r\r%rCrir rYr_rbrgrMrÊ)r”rZ    cat_codesr‡r_rbrururvÚfactorize_from_iterableí    s  r®z$tuple[list[np.ndarray], list[Index]]cCs:t|ƒdkrggfStdd„|DƒŽ\}}t|ƒt|ƒfS)a$
    A higher-level wrapper over `factorize_from_iterable`.
 
    Parameters
    ----------
    iterables : list-like of list-likes
 
    Returns
    -------
    codes : list of ndarrays
    categories : list of Indexes
 
    Notes
    -----
    See `factorize_from_iterable` for more info.
    rcss|]}t|ƒVqdSr)r®)r€Úitrururvrƒ+
sz+factorize_from_iterables.<locals>.<genexpr>)rYrhr)Ú    iterablesrbr_rururvÚfactorize_from_iterables
s r±)T)wÚ
__future__rÚcsvrÚ    functoolsrryÚshutilrÚtypingrrrr    r
r r r ÚnumpyriZpandas._configrZ pandas._libsrrrgrZpandas._libs.arraysrZpandas._typingrrrrrrrrrrZpandas.compat.numpyrrlZpandas.util._validatorsrZpandas.core.dtypes.castrr Zpandas.core.dtypes.commonr!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0Zpandas.core.dtypes.dtypesr1r2Zpandas.core.dtypes.genericr3r4Zpandas.core.dtypes.missingr5r6Z pandas.corer7r8r9Zpandas.core.accessorr:r;Zpandas.core.algorithmsr<r=Zpandas.core.arrays._mixinsr>r?Zpandas.core.baser@rArBZpandas.core.commonÚcoreÚcommonrœZpandas.core.constructionrCrDZpandas.core.ops.commonrEZpandas.core.sortingrFZ pandas.core.strings.object_arrayrGrIrHrÁrIrJrKrLr{rŠrMr¡r¢rar®r±rurururvÚ<module>s–    (   0  H     I3+ÿø
ôÿ+)