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
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
U
¬ý°dÕaã@s@dZddlmZddlmZddlmZddlmZddl    m
Z
m Z m Z m Z mZmZmZmZmZmZmZmZddlZddlmZmZmZdd    lmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'dd
l(m)Z)dd l*m+Z+m,Z,m-Z-dd l.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6dd l7m8Z8m9Z9ddl:m;Z;ddl<m=Z=m>Z>m?Z?m@Z@ddlAmBmCZDddlEmFZFddlGmHZHddlImJZJmKZKmLZLmMZMmNZNddlOmPZPmQZQmRZRmSZSddlTmUZUddlVmWZWddlXmYZYe
rÔddlZm[Z[ddl\m]Z]ee^e de ffZ_edƒZ`Gdd„deƒZaGdd„deJeUƒZbGdd „d eJeFƒZcd!d!d"d!d#œd$d%„ZddS)&zî
Define the SeriesGroupBy and DataFrameGroupBy
classes that hold the groupby interfaces (and some implementations).
 
These are user facing as the result of the ``df.groupby(...)`` operations,
which here returns a DataFrameGroupBy object.
é)Ú annotations)Úabc)Úpartial)Údedent) Ú TYPE_CHECKINGÚAnyÚCallableÚHashableÚIterableÚLiteralÚMappingÚ
NamedTupleÚSequenceÚTypeVarÚUnionÚcastN)ÚIntervalÚlibÚ    reduction)
Ú    ArrayLikeÚAxisÚAxisIntÚCorrelationMethodÚ FillnaOptionsÚ
IndexLabelÚManagerÚ    Manager2DÚ SingleManagerÚ TakeIndexer)ÚSpecificationError)ÚAppenderÚ SubstitutionÚdoc)Ú ensure_int64Úis_boolÚis_categorical_dtypeÚ is_dict_likeÚis_integer_dtypeÚis_interval_dtypeÚis_numeric_dtypeÚ    is_scalar)ÚisnaÚnotna)Ú
algorithms)Ú GroupByApplyÚmaybe_mangle_lambdasÚreconstruct_funcÚvalidate_func_kwargs)Ú    DataFrame)Úbase)ÚGroupByÚ GroupByPlotÚ _agg_templateÚ _apply_docsÚ_transform_template)ÚIndexÚ
MultiIndexÚall_indexes_sameÚ default_index)ÚSeries)Úmaybe_use_numba)Úboxplot_frame_groupby)Ú Categorical)ÚNDFrame.Ú ScalarResultc@s"eZdZUdZded<ded<dS)ÚNamedAggaæ
    Helper for column specific aggregation with control over output column names.
 
    Subclass of typing.NamedTuple.
 
    Parameters
    ----------
    column : Hashable
        Column label in the DataFrame to apply aggfunc.
    aggfunc : function or str
        Function to apply to the provided column. If string, the name of a built-in
        pandas function.
 
    Examples
    --------
    >>> df = pd.DataFrame({"key": [1, 1, 2], "a": [-1, 0, 1], 1: [10, 11, 12]})
    >>> agg_a = pd.NamedAgg(column="a", aggfunc="min")
    >>> agg_1 = pd.NamedAgg(column=1, aggfunc=np.mean)
    >>> df.groupby("key").agg(result_a=agg_a, result_1=agg_1)
         result_a  result_1
    key
    1          -1      10.5
    2           1      12.0
    r    ÚcolumnÚ    AggScalarZaggfuncN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú__annotations__©rKrKúRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/groupby/generic.pyrCms
rCc s@eZdZdddœdd„Zdddœd    d
d d œd d„Zddœdd„ZedƒZee    dj
de    ddƒddœ‡fdd„ ƒZ e e eddddddœdd„ƒZeZdd„Zd dœd!d"„Zd€dd#d    d    d$d%œd&d'„Zd(d)„Zed*ƒZeded+eeƒdddœd,d-„ƒƒZdd/d    d0d1œd2d3„Zd4dd5œd6d7„Zd‚d    d9œd:d;„Zdƒd    d<d=œd>d?„Ze ejƒ‡fd@dA„ƒZd„d    d    d    d    d<dBœdCdD„Zd…dEdFdGd    dHdIdJdKœdLdM„Zd†dNdOddPœdQdR„Z e!j"d8dfdSd    d    ddTœdUdV„Z#e$e ej%j&ƒdWdX„ƒƒZ%e ej'j&ƒd‡d[d\dd]œd^d_„ƒZ'e ej(j&ƒdˆd[d\dd]œd`da„ƒZ(e ej)j&ƒd‰dOd    ddbœdcdd„ƒZ)e ej*j&ƒdŠdOd    ddbœdedf„ƒZ*e ej+j&ƒd‹ddhdHddiœdjdk„ƒZ+e ej,j&ƒdŒddHdHddmœdndo„ƒZ,e$e ej-j&ƒddœdpdq„ƒƒZ-e$e ej.j&ƒddœdrds„ƒƒZ.e ej/j&ƒdd    dHdudHdudvdwd
d    dxœ    dydz„ƒZ/e$e ej0j&ƒddœd{d|„ƒƒZ0e ej1j&ƒddœd}d~„ƒZ1‡Z2S)ŽÚ SeriesGroupByrr=©ÚmgrÚreturncCs|jj||jjdS)N©Úname)ÚobjÚ _constructorrR©ÚselfrOrKrKrLÚ_wrap_agged_managerŒsz!SeriesGroupBy._wrap_agged_managerFN©Ú numeric_onlyrRÚboolú
str | Noner©rYrRrPcCsD|j}|j}|r@t|jƒs@d}td|›dt|ƒj›d|›dƒ‚|S)NrYz Cannot use z =True with Ú.z and non-numeric dtypes.)Ú _selected_objÚ_mgrr)ÚdtypeÚ    TypeErrorÚtyperF)rVrYrRÚserZsingleZkwd_namerKrKrLÚ_get_data_to_aggregatesÿz$SeriesGroupBy._get_data_to_aggregateúIterable[Series]©rPccs |jVdS©N)r^©rVrKrKrLÚ_iterate_slicesszSeriesGroupBy._iterate_slicesa§
    Examples
    --------
    >>> s = pd.Series([1, 2, 3, 4])
 
    >>> s
    0    1
    1    2
    2    3
    3    4
    dtype: int64
 
    >>> s.groupby([1, 1, 2, 2]).min()
    1    1
    2    3
    dtype: int64
 
    >>> s.groupby([1, 1, 2, 2]).agg('min')
    1    1
    2    3
    dtype: int64
 
    >>> s.groupby([1, 1, 2, 2]).agg(['min', 'max'])
       min  max
    1    1    2
    2    3    4
 
    The output column names can be controlled by passing
    the desired column names and aggregations as keyword arguments.
 
    >>> s.groupby([1, 1, 2, 2]).agg(
    ...     minimum='min',
    ...     maximum='max',
    ... )
       minimum  maximum
    1        1        2
    2        3        4
 
    .. versionchanged:: 1.3.0
 
        The resulting dtype will reflect the return value of the aggregating function.
 
    >>> s.groupby([1, 1, 2, 2]).agg(lambda x: x.astype(float).min())
    1    1.0
    2    3.0
    dtype: float64
    ÚtemplateZseriesZseries_examples)ÚinputÚexamplescstƒj|f|ž|ŽSrg)ÚsuperÚapply)rVÚfuncÚargsÚkwargs©Ú    __class__rKrLrnÒszSeriesGroupBy.apply©rlÚklass©ÚengineÚ engine_kwargsc Os|t|ƒr"|j|f|žd|i|—ŽS|dk}d}|rBt|ƒ\}}i}t|tƒr\t||ƒ||ŽSt|tjƒrªt|ƒ}|j    |f|ž|Ž}|r˜|dk    s’t
‚||_ |j s¦|  ¡}|St |¡}    |    rÌ|sÌ|sÌt||    ƒƒS|jdkrü|j}
|jjg|jj|jj|
jdS|jjdkr|j|f|ž|ŽSz|j|f|ž|ŽWStk
rv|j|f|ž|Ž} t| |jjd} | | ¡} | YSXdS)Nrxr©rRÚindexr`é©rz)r>Ú_aggregate_with_numbar1Ú
isinstanceÚstrÚgetattrrr
r/Ú_aggregate_multiple_funcsÚAssertionErrorÚcolumnsÚas_indexÚ reset_indexÚcomZget_cython_funcÚngroupsÚ_obj_with_exclusionsrSrTrRÚgrouperÚ result_indexr`ÚnkeysÚ_python_agg_generalÚKeyErrorÚ_aggregate_namedr=Ú_wrap_aggregated_output) rVrorwrxrprqÚ
relabelingrƒÚretZcyfuncrSÚresultrKrKrLÚ    aggregateÚs\ÿÿÿÿ 
 
   ü
zSeriesGroupBy.aggregatecsHt ˆ¡‰‡‡‡fdd„}|j}|j ||¡}|j||jd}| |¡S)Ncsˆ|fˆžˆŽSrgrK©Úx©rprorqrKrLÚ<lambda>óz3SeriesGroupBy._python_agg_general.<locals>.<lambda>rQ)r†Úis_builtin_funcrˆr‰Ú
agg_seriesrTrRr)rVrorprqÚfrSr’ÚresrKr–rLrŒs 
z!SeriesGroupBy._python_agg_generalr2c    OsLt|tƒr(|jrtdƒ‚qvt| ¡ƒ}nNtdd„|DƒƒrJdd„|Dƒ}n,g}|D]}| t     |¡pf|¡qRt
||ƒ}i}t  |dd¡@t |ƒD]0\}\}}    t j||d}
|j|    f|ž|Ž||
<q’W5QRXtd    d„| ¡Dƒƒrd
d lm} | | ¡d d d„|Dƒd} | Sdd„| ¡Dƒ} |jj| dd}tdd„|Dƒƒ|_|S)Nznested renamer is not supportedcss|]}t|ttfƒVqdSrg©r~ÚtupleÚlist©Ú.0r•rKrKrLÚ    <genexpr>,sz:SeriesGroupBy._aggregate_multiple_funcs.<locals>.<genexpr>cSs&g|]}t|ttfƒs||fn|‘qSrKrr rKrKrLÚ
<listcomp>-sz;SeriesGroupBy._aggregate_multiple_funcs.<locals>.<listcomp>r„T©ÚlabelÚpositioncss|]}t|tƒVqdSrg)r~r2r rKrKrLr¢>sr©Úconcatr{cSsg|]
}|j‘qSrK©r¥©r¡ÚkeyrKrKrLr£Bs)ÚaxisÚkeyscSsi|]\}}|j|“qSrK©r¦©r¡r«ÚvalrKrKrLÚ
<dictcomp>Fsz;SeriesGroupBy._aggregate_multiple_funcs.<locals>.<dictcomp>r|css|] }|jVqdSrgr©rªrKrKrLr¢Hs)r~Údictr„rrŸÚitemsÚanyÚappendr†Zget_callable_nameÚzipZ temp_setattrÚ    enumerater3Ú    OutputKeyr“ÚvaluesÚpandasr¨rSÚ_constructor_expanddimr9rƒ)rVÚargrprqrƒr›ÚresultsÚidxrRror«r¨Úres_dfÚindexed_outputÚoutputrKrKrLr$s6
 
 
"  ÿz'SeriesGroupBy._aggregate_multiple_funcsz    list[Any]úDataFrame | Series)Údatar¹Únot_indexed_sameÚ is_transformrPc
Cs6t|ƒdkr:|r|j}n|jj}|jjg|jj||jdS|dk    sFt‚t    |dt
ƒr’|jj}|jj ||d}|  |¡}|j |jd}|jj|_|St    |dttfƒrî|j|||d}    t    |    tƒrÈ|jj|    _|jsê|rê| |    ¡}    tt|    ƒƒ|    _|    S|jj||jj|jjd}    |js(| |    ¡}    tt|    ƒƒ|    _|  |    ¡SdS)aÃ
        Wrap the output of SeriesGroupBy.apply into the expected result.
 
        Parameters
        ----------
        data : Series
            Input data for groupby operation.
        values : List[Any]
            Applied output for each group.
        not_indexed_same : bool, default False
            Whether the applied outputs are not indexed the same as the group axes.
 
        Returns
        -------
        DataFrame or Series
        rryNr|©Údropna©rÄrÅ)rÃrzrR)Úlenrzr‰rŠrSrTrRr`r‚r~r²r»Ú_reindex_outputÚstackÚobservedr=r2Ú_concat_objectsr„Ú_insert_inaxis_grouperr<)
rVrÃr¹rÄrÅÚ    res_indexrzr¿Zres_serr’rKrKrLÚ_wrap_applied_outputLsN ü 
 
ý
 
 
 
ÿ
z"SeriesGroupBy._wrap_applied_outputc    Os`i}d}|D]N\}}t |d|¡||f|ž|Ž}t |¡}|sRt ||j¡d}|||<q |S)NFrRT)ÚobjectÚ __setattr__Ú libreductionZextract_resultZcheck_result_arrayr`)    rVrorprqr’Z initializedrRÚgrouprÁrKrKrLrŽ“s 
 
zSeriesGroupBy._aggregate_nameda)
    >>> ser = pd.Series(
    ...    [390.0, 350.0, 30.0, 20.0],
    ...    index=["Falcon", "Falcon", "Parrot", "Parrot"],
    ...    name="Max Speed")
    >>> grouped = ser.groupby([1, 1, 2, 2])
    >>> grouped.transform(lambda x: (x - x.mean()) / x.std())
        Falcon    0.707107
        Falcon   -0.707107
        Parrot    0.707107
        Parrot   -0.707107
        Name: Max Speed, dtype: float64
 
    Broadcast result of the transformation
 
    >>> grouped.transform(lambda x: x.max() - x.min())
    Falcon    40.0
    Falcon    40.0
    Parrot    10.0
    Parrot    10.0
    Name: Max Speed, dtype: float64
 
    >>> grouped.transform("mean")
    Falcon    370.0
    Falcon    370.0
    Parrot     25.0
    Parrot     25.0
    Name: Max Speed, dtype: float64
 
    .. versionchanged:: 1.3.0
 
    The resulting dtype will reflect the return value of the passed ``func``,
    for example:
 
    >>> grouped.transform(lambda x: x.astype(int).max())
    Falcon    390
    Falcon    390
    Parrot     30
    Parrot     30
    Name: Max Speed, dtype: int64
    ©ruZexamplecOs|j|f|ž||dœ|—ŽS©Nrv©Z
_transform©rVrorwrxrprqrKrKrLÚ    transformÒsÿÿÿÿzSeriesGroupBy.transformrrr)ÚhowrYr¬c
Ks€|dks t‚|j}z|jjd|j||f|Ž}Wn:tk
rh}zt|›d|j›dƒ|‚W5d}~XYnX|j||j    j
|j dS)NrrÙz is not supported for z dtype©rzrR) r‚r^r‰Ú_cython_operationÚ_valuesÚNotImplementedErrorrar`rTrSrzrR)rVrÚrYr¬rqrSr’ÚerrrKrKrLÚ_cython_transformÙs ÿÿ*zSeriesGroupBy._cython_transformr)rorPc Os¬t|ƒs t‚t|jƒ}g}|jj|j|jdD]:\}}t     |d|¡||f|ž|Ž}| 
|||j d¡q.|rŽddl m }    |    |ƒ}
| |
¡} n|jjtjd} |jj| _| S)z2
        Transform with a callable func`.
        ©r¬rRr|rr§©r`)Úcallabler‚rbrSr‰Ú get_iteratorr^r¬rÑrÒrµrzÚpandas.core.reshape.concatr¨Ú_set_result_index_orderedrTÚnpÚfloat64rR) rVrorprqrur½rRrÔrœr¨Ú concatenatedr’rKrKrLÚ_transform_generalês" 
ÿ  
z SeriesGroupBy._transform_generalTrÆc
s˜tˆtƒr‡‡‡fdd„‰n‡‡‡fdd„‰ddœ‡fdd„ ‰z‡‡fdd    „ˆDƒ}Wn0ttfk
r†}ztd
ƒ|‚W5d }~XYnXˆ ||¡}|S) a°
        Filter elements from groups that don't satisfy a criterion.
 
        Elements from groups are filtered if they do not satisfy the
        boolean criterion specified by func.
 
        Parameters
        ----------
        func : function
            Criterion to apply to each group. Should return True or False.
        dropna : bool
            Drop groups that do not pass the filter. True by default; if False,
            groups that evaluate False are filled with NaNs.
 
        Returns
        -------
        Series
 
        Notes
        -----
        Functions that mutate the passed object can produce unexpected
        behavior or errors and are not supported. See :ref:`gotchas.udf-mutation`
        for more details.
 
        Examples
        --------
        >>> df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
        ...                           'foo', 'bar'],
        ...                    'B' : [1, 2, 3, 4, 5, 6],
        ...                    'C' : [2.0, 5., 8., 1., 2., 9.]})
        >>> grouped = df.groupby('A')
        >>> df.groupby('A').B.filter(lambda x: x.mean() > 3.)
        1    2
        3    4
        5    6
        Name: B, dtype: int64
        cst|ˆƒˆˆŽSrg©r€r”r–rKrLr—.r˜z&SeriesGroupBy.filter.<locals>.<lambda>csˆ|fˆžˆŽSrgrKr”r–rKrLr—0r˜rZrfcsˆ|ƒ}t|ƒo|Srg)r,)r•Úb)ÚwrapperrKrLÚtrue_and_notna3sz,SeriesGroupBy.filter.<locals>.true_and_notnacs"g|]\}}ˆ|ƒrˆ |¡‘qSrK)Ú
_get_index)r¡rRrÔ)rVrîrKrLr£8sz(SeriesGroupBy.filter.<locals>.<listcomp>z'the filter must return a boolean resultN)r~rÚ
ValueErrorraÚ _apply_filter)rVrorÇrprqÚindicesrßÚfilteredrK)rprorqrVrîrírLÚfilters&
 ÿ
 zSeriesGroupBy.filterzSeries | DataFrame©rÇrPc    CsÌ|jj\}}}|jj}tj|dd\}}t ||f¡}||}||}tjddt     |dd…|dd…k¡df}tjd|dd…|dd…kf}|dk}    |r¶d||<d||    <n&d||    tjd|    dd…f@<d||<tj
  ||¡j ddd}
t |ƒr.|ddkr(|
dd…} |t |¡}n|
} n |
dd…} |jj} t | ƒt | ƒkrˆtjt | ƒ|
jd    | } }
t |ƒdkrˆ|
| ||<|jj| | |jjd
} |js¾| | ¡} tt | ƒƒ| _|j| dd S) z§
        Return number of unique elements in the group.
 
        Returns
        -------
        Series
            Number of unique values within each group.
        F©Úsortrr{NéÿÿÿÿÚint64©ÚcopyrârÛ)Ú
fill_value)r‰Ú
group_inforSrÝr-Ú    factorizerçÚlexsortÚr_ÚnonzeroÚaddÚreduceatÚastyperÉZ flatnonzerorŠÚzerosr`rTrRr„rÎr<rzrÊ)rVrÇÚidsÚ_r°ÚcodesÚsorterr¾ÚincÚmaskÚoutrœÚrir’rKrKrLÚnuniqueAsF    0"
 
   ÿ
zSeriesGroupBy.nuniquec stƒjf|ŽSrg)rmÚdescribe)rVrqrrrKrLr}szSeriesGroupBy.describe)Ú    normalizer÷Ú    ascendingrÇrPc&s|rdnd}|dkr0|j||||d}||_|Sddlm}ddlm}    |jj\}
} } |jj    } |jj
|jjg} t | j ƒsŒ|dk    r´t  |¡s´|jtj||||d}||_| |j_
|S|
dk‰|
ˆ| ˆ}
} |dkròtj| d    d
\}}d d „}nD|    t| d d|d    d}td|j    ƒ}|j}|j|jd    |jd}dd „}t|j ƒrbtt|ƒ}t  |j|j|
f¡}nt  ||
f¡}|
|||}
}dt  |
dd…|
dd…k¡d}t j d|f}t!|
ƒsÄ|}||t"ddƒƒ||t"ddƒƒk}t j d    |f}t!| ƒs|}d    ||<t  #t  t j |d    f¡d¡}t$t j%t j& '||¡d‰|jj(}‡fdd„|Dƒ|||ƒg}dd„|jj)Dƒ|g}|rº|ddk‰ˆ *¡ržd }n|ˆ‡fdd„|Dƒ}}|r"| +d¡}t  #t j |t!|
ƒf¡}|r|
|dk}t j& ,||d¡ˆ|ƒˆ}nˆ|ƒ}||}|r€|dkr€|rD|
|ˆn|
|} t  |rZ|n| | f¡}|||d|}|d<|dk    rÊt j-t!|ƒdd‰|dd…D],}!ˆt j d    |!dd…|!dd…kfO‰q¨ˆ .¡t!|dƒ}"‰t  %t  /|"¡ˆ¡t  0t  /ˆ¡|"¡g}#ˆ 1¡d|dg}$||#|$d dd\} }t  2|dk||d¡}|rŒt  |rb|n| |#df¡}|||#d|}|#d<dddœ‡‡fd d!„ ‰‡fd"d„|dd…Dƒ}| 3|#d¡t4||| d d#}%t5|j ƒrît6|ƒ}|jj7||%|d$}|j8s| 9¡}|S)%NZ
proportionÚcount)rr÷rrÇr)Úget_join_indexers)Úcut)rr÷rÚbinsrøTröcSs||SrgrK©Úlabr
rKrKrLr—±r˜z,SeriesGroupBy.value_counts.<locals>.<lambda>Frú)Zinclude_lowestr@)Z
allow_fillrücSs||jjdS)Nrø)Z _multiindexrrrKrKrLr—¼r˜r{)Zrepeatscsg|] }ˆ|ƒ‘qSrKrK©r¡Ú level_codes)ÚreprKrLr£Ûsz.SeriesGroupBy.value_counts.<locals>.<listcomp>cSsg|]
}|j‘qSrK)Z group_index)r¡ZpingrKrKrLr£Üscsg|] }|ˆ‘qSrKrKr)r rKrLr£ãsÚfloatrZrâÚleft)r÷rÚz
np.ndarray)Ú    lev_codesrPcst |ˆˆ¡Srg)rçÚrepeat)r)ÚdiffÚnbinrKrLÚ build_codes
sz/SeriesGroupBy.value_counts.<locals>.build_codescsg|] }ˆ|ƒ‘qSrKrK)r¡r)r!rKrLr£ s)ÚlevelsrÚnamesÚverify_integrityrÛ):Ú _value_countsrRZpandas.core.reshape.mergerZpandas.core.reshape.tilerr‰rýrSrÝr#r%r`rçÚiterablernr=Ú value_countsrzr-rþrÚ
categoriesÚtakerZ    _na_valuer(rrÿrÚrightrrrÉÚslicerrrrrZreconstructed_codesZ    groupingsÚallrÚatrÚsumZarangeÚtileZcumsumÚwhererµr:r'r#rTr„r…)&rVrr÷rrrÇrRr’rrrrr°Z index_namesrcrZlevZllabZcat_serZcat_objZ lab_intervalr    Z    idchangesr¾Zlchangesr
r rr"ÚdÚmÚaccÚcatrZncatrr*ÚmirK)r!rr r rrLr'sØ ÿ  
ÿÿû
 ý 
&
 
 
 
 
*$ÿ zSeriesGroupBy.value_countszobject | ArrayLike | NoneúFillnaOptions | Noneú Axis | Noneú
int | Nonez dict | Nonez Series | None)ÚvalueÚmethodr¬ÚinplaceÚlimitÚdowncastrPc    Cs|jd||||||d}|S)a
        Fill NA/NaN values using the specified method within groups.
 
        Parameters
        ----------
        value : scalar, dict, Series, or DataFrame
            Value to use to fill holes (e.g. 0), alternately a
            dict/Series/DataFrame of values specifying which value to use for
            each index (for a Series) or column (for a DataFrame).  Values not
            in the dict/Series/DataFrame will not be filled. This value cannot
            be a list. Users wanting to use the ``value`` argument and not ``method``
            should prefer :meth:`.Series.fillna` as this
            will produce the same result and be more performant.
        method : {{'bfill', 'ffill', None}}, default None
            Method to use for filling holes. ``'ffill'`` will propagate
            the last valid observation forward within a group.
            ``'bfill'`` will use next valid observation to fill the gap.
        axis : {0 or 'index', 1 or 'columns'}
            Unused, only for compatibility with :meth:`DataFrameGroupBy.fillna`.
        inplace : bool, default False
            Broken. Do not set to True.
        limit : int, default None
            If method is specified, this is the maximum number of consecutive
            NaN values to forward/backward fill within a group. In other words,
            if there is a gap with more than this number of consecutive NaNs,
            it will only be partially filled. If method is not specified, this is the
            maximum number of entries along the entire axis where NaNs will be
            filled. Must be greater than 0 if not None.
        downcast : dict, default is None
            A dict of item->dtype of what to downcast if possible,
            or the string 'infer' which will try to downcast to an appropriate
            equal type (e.g. float64 to int64 if possible).
 
        Returns
        -------
        Series
            Object with missing values filled within groups.
 
        See Also
        --------
        ffill : Forward fill values within a group.
        bfill : Backward fill values within a group.
 
        Examples
        --------
        >>> ser = pd.Series([np.nan, np.nan, 2, 3, np.nan, np.nan])
        >>> ser
        0    NaN
        1    NaN
        2    2.0
        3    3.0
        4    NaN
        5    NaN
        dtype: float64
 
        Propagate non-null values forward or backward within each group.
 
        >>> ser.groupby([0, 0, 0, 1, 1, 1]).fillna(method="ffill")
        0    NaN
        1    NaN
        2    2.0
        3    3.0
        4    3.0
        5    3.0
        dtype: float64
 
        >>> ser.groupby([0, 0, 0, 1, 1, 1]).fillna(method="bfill")
        0    2.0
        1    2.0
        2    2.0
        3    3.0
        4    NaN
        5    NaN
        dtype: float64
 
        Only replace the first NaN element within a group.
 
        >>> ser.groupby([0, 0, 0, 1, 1, 1]).fillna(method="ffill", limit=1)
        0    NaN
        1    NaN
        2    2.0
        3    3.0
        4    3.0
        5    NaN
        dtype: float64
        Úfillna©r9r:r¬r;r<r=©Z _op_via_apply©rVr9r:r¬r;r<r=r’rKrKrLr>s_ù    zSeriesGroupBy.fillnarr©ròr¬rPcKs|jd||dœ|—Ž}|S)aû
 
        Return the elements in the given *positional* indices in each group.
 
        This means that we are not indexing according to actual values in
        the index attribute of the object. We are indexing according to the
        actual position of the element in the object.
 
        If a requested index does not exist for some group, this method will raise.
        To get similar behavior that ignores indices that don't exist, see
        :meth:`.SeriesGroupBy.nth`.
 
        Parameters
        ----------
        indices : array-like
            An array of ints indicating which positions to take in each group.
        axis : {0 or 'index', 1 or 'columns', None}, default 0
            The axis on which to select elements. ``0`` means that we are
            selecting rows, ``1`` means that we are selecting columns.
            For `SeriesGroupBy` this parameter is unused and defaults to 0.
        **kwargs
            For compatibility with :meth:`numpy.take`. Has no effect on the
            output.
 
        Returns
        -------
        Series
            A Series containing the elements taken from each group.
 
        See Also
        --------
        Series.take : Take elements from a Series along an axis.
        Series.loc : Select a subset of a DataFrame by labels.
        Series.iloc : Select a subset of a DataFrame by positions.
        numpy.take : Take elements from an array along an axis.
        SeriesGroupBy.nth : Similar to take, won't raise if indices don't exist.
 
        Examples
        --------
        >>> df = pd.DataFrame([('falcon', 'bird', 389.0),
        ...                    ('parrot', 'bird', 24.0),
        ...                    ('lion', 'mammal', 80.5),
        ...                    ('monkey', 'mammal', np.nan),
        ...                    ('rabbit', 'mammal', 15.0)],
        ...                   columns=['name', 'class', 'max_speed'],
        ...                   index=[4, 3, 2, 1, 0])
        >>> df
             name   class  max_speed
        4  falcon    bird      389.0
        3  parrot    bird       24.0
        2    lion  mammal       80.5
        1  monkey  mammal        NaN
        0  rabbit  mammal       15.0
        >>> gb = df["name"].groupby([1, 1, 2, 2, 2])
 
        Take elements at positions 0 and 1 along the axis 0 in each group (default).
 
        >>> gb.take([0, 1])
        1  4    falcon
           3    parrot
        2  2      lion
           1    monkey
        Name: name, dtype: object
 
        We may take elements using negative integers for positive indices,
        starting from the end of the object, just like with Python lists.
 
        >>> gb.take([-1, -2])
        1  3    parrot
           4    falcon
        2  0    rabbit
           1    monkey
        Name: name, dtype: object
        r)©ròr¬)r)r@©rVròr¬rqr’rKrKrLr)…sOzSeriesGroupBy.takezAxis | lib.NoDefault©r¬ÚskipnarYrPcKs|jd|||dœ|—Ž}|S)a(
        Return unbiased skew within groups.
 
        Normalized by N-1.
 
        Parameters
        ----------
        axis : {0 or 'index', 1 or 'columns', None}, default 0
            Axis for the function to be applied on.
            This parameter is only for compatibility with DataFrame and is unused.
 
        skipna : bool, default True
            Exclude NA/null values when computing the result.
 
        numeric_only : bool, default False
            Include only float, int, boolean columns. Not implemented for Series.
 
        **kwargs
            Additional keyword arguments to be passed to the function.
 
        Returns
        -------
        Series
 
        See Also
        --------
        Series.skew : Return unbiased skew over requested axis.
 
        Examples
        --------
        >>> ser = pd.Series([390., 350., 357., np.nan, 22., 20., 30.],
        ...                 index=['Falcon', 'Falcon', 'Falcon', 'Falcon',
        ...                        'Parrot', 'Parrot', 'Parrot'],
        ...                 name="Max Speed")
        >>> ser
        Falcon    390.0
        Falcon    350.0
        Falcon    357.0
        Falcon      NaN
        Parrot     22.0
        Parrot     20.0
        Parrot     30.0
        Name: Max Speed, dtype: float64
        >>> ser.groupby(level=0).skew()
        Falcon    1.525174
        Parrot    1.457863
        Name: Max Speed, dtype: float64
        >>> ser.groupby(level=0).skew(skipna=False)
        Falcon         NaN
        Parrot    1.457863
        Name: Max Speed, dtype: float64
        Úskew©r¬rFrY)rGr@©rVr¬rFrYrqr’rKrKrLrG×s;ÿüûzSeriesGroupBy.skewcCs t|ƒ}|Srg©r5©rVr’rKrKrLÚplotszSeriesGroupBy.plotéÚfirstÚintz!Literal[('first', 'last', 'all')])ÚnÚkeeprPcCs*ttj||d}|j}|j||dd}|S©N)rPrQT©rÄ)rr=Únlargestr^Ú_python_apply_general©rVrPrQr›rÃr’rKrKrLrT!szSeriesGroupBy.nlargestcCs*ttj||d}|j}|j||dd}|SrR)rr=Ú    nsmallestr^rUrVrKrKrLrW,szSeriesGroupBy.nsmallest)r¬rFrPcCs|jd||d}|S)NÚidxmin©r¬rFr@©rVr¬rFr’rKrKrLrX7szSeriesGroupBy.idxmincCs|jd||d}|S)NÚidxmaxrYr@rZrKrKrLr[<szSeriesGroupBy.idxmaxÚpearsonr)Úotherr:Ú min_periodsrPcCs|jd|||d}|S)NÚcorr)r]r:r^r@)rVr]r:r^r’rKrKrLr_AsÿzSeriesGroupBy.corrr{)r]r^ÚddofrPcCs|jd|||d}|S)NÚcov)r]r^r`r@)rVr]r^r`r’rKrKrLraMsÿzSeriesGroupBy.covcCs| dd„¡S)NcSs|jSrg)Úis_monotonic_increasing©rcrKrKrLr—Yr˜z7SeriesGroupBy.is_monotonic_increasing.<locals>.<lambda>©rnrhrKrKrLrbVsz%SeriesGroupBy.is_monotonic_increasingcCs| dd„¡S)NcSs|jSrg)Úis_monotonic_decreasingrcrKrKrLr—^r˜z7SeriesGroupBy.is_monotonic_decreasing.<locals>.<lambda>rdrhrKrKrLre[sz%SeriesGroupBy.is_monotonic_decreasingé
ú float | Noneútuple[int, int] | Noneúint | Sequence[int])    ÚgridÚ
xlabelsizeÚxrotÚ
ylabelsizeÚyrotÚfigsizerÚbackendÚlegendc Ks,|jd|||||||||    |
| dœ | —Ž} | S)NÚhist) ÚbyÚaxrjrkrlrmrnrorrprq)rrr@)rVrsrtrjrkrlrmrnrorrprqrqr’rKrKrLrr`s$ÿô ózSeriesGroupBy.histcCs| dd„¡S)NcSs|jSrgrârcrKrKrLr—„r˜z%SeriesGroupBy.dtype.<locals>.<lambda>rdrhrKrKrLr`szSeriesGroupBy.dtypecCs| d¡}|S)NÚuniquer@rKrKrKrLru†s
zSeriesGroupBy.unique)N)FF)Fr)T)T)FTFNT)NNNFNN)r)rMrN)rMrN)rT)rT)r\N)Nr{) NNTNNNNNrfNF)3rFrGrHrWrdrirÚ_agg_examples_docr r7Úformatrnr"r6r“ÚaggrŒrrÐrŽZ#_SeriesGroupBy__examples_series_docr!r8rÙràrêrôrr=rr'r>r)rÚ
no_defaultrGÚpropertyrLrIrTrWrXr[r_rarbrerrr`ruÚ __classcell__rKrKrrrLrM‹sÒÿÿ2ÿÿ >    ,ûGÿ,
ÿ:<úùmýTüD
 
ÿ
 
ÿ
 
 
 
ü
ÿ
 
 
ô" 
 
rMcsúeZdZedƒZeeedddƒdddœdd„ƒZeZdd    „Z    d
d œd d „Z
dd œdd„Z d„dddddœdd„Z ddddddœdd„Z d…dddddœd d!„Zd"d#„Zed$ƒZeded%eeƒdddœd&d'„ƒƒZd(d)„Zd*d*dd+œd,d-„Zd†dd/œd0d1„Zd2d œ‡fd3d4„ Zd‡d5d6œd7d8„Zddd9œdd:d;d<œd=d>„Zd?dd@œdAdB„Zd;ddCœdDdE„ZddFœdGdH„ZdddIœdJdK„ZdˆdddLœdMdN„Zd‰dOddddPœdQdR„Z dŠdOddddPœdSdT„Z!e"Z#d‹dUddddddVœdWdX„Z$dŒdYdZdOdd[d\œd]d^„Z%dd_dOdd`œdadb„Z&e'j(d.dfdcddddPœddde„Z)e*ee+j,j-ƒdfd œdgdh„ƒƒZ,ee+j.j-ƒdŽdkd5dddlœdmdn„ƒZ.ee+j/j-ƒddododddpœdqdr„ƒZ/ee+j0j-ƒddtddodudodudddvdvdwd:ddxœ dydz„ƒZ0e*ee+j1j-ƒd{d œd|d}„ƒƒZ1ee+j2j-ƒd‘dd~ddddd€œdd‚„ƒZ2‡Z3S)’ÚDataFrameGroupByaª
    Examples
    --------
    >>> df = pd.DataFrame(
    ...     {
    ...         "A": [1, 1, 2, 2],
    ...         "B": [1, 2, 3, 4],
    ...         "C": [0.362838, 0.227877, 1.267767, -0.562860],
    ...     }
    ... )
 
    >>> df
       A  B         C
    0  1  1  0.362838
    1  1  2  0.227877
    2  2  3  1.267767
    3  2  4 -0.562860
 
    The aggregation is for each column.
 
    >>> df.groupby('A').agg('min')
       B         C
    A
    1  1  0.227877
    2  3 -0.562860
 
    Multiple aggregations
 
    >>> df.groupby('A').agg(['min', 'max'])
        B             C
      min max       min       max
    A
    1   1   2  0.227877  0.362838
    2   3   4 -0.562860  1.267767
 
    Select a column for aggregation
 
    >>> df.groupby('A').B.agg(['min', 'max'])
       min  max
    A
    1    1    2
    2    3    4
 
    User-defined function for aggregation
 
    >>> df.groupby('A').agg(lambda x: sum(x) + 2)
        B           C
    A
    1    5    2.590715
    2    9    2.704907
 
    Different aggregations per column
 
    >>> df.groupby('A').agg({'B': ['min', 'max'], 'C': 'sum'})
        B             C
      min max       sum
    A
    1   1   2  0.590715
    2   3   4  0.704907
 
    To control the output names with different aggregations per column,
    pandas supports "named aggregation"
 
    >>> df.groupby("A").agg(
    ...     b_min=pd.NamedAgg(column="B", aggfunc="min"),
    ...     c_sum=pd.NamedAgg(column="C", aggfunc="sum"))
       b_min     c_sum
    A
    1      1  0.590715
    2      3  0.704907
 
    - The keywords are the *output* column names
    - The values are tuples whose first element is the column to select
      and the second element is the aggregation to apply to that column.
      Pandas provides the ``pandas.NamedAgg`` namedtuple with the fields
      ``['column', 'aggfunc']`` to make it clearer what the arguments are.
      As usual, the aggregation can be a callable or a string alias.
 
    See :ref:`groupby.aggregate.named` for more.
 
    .. versionchanged:: 1.3.0
 
        The resulting dtype will reflect the return value of the aggregating function.
 
    >>> df.groupby("A")[["B"]].agg(lambda x: x.astype(float).min())
          B
    A
    1   1.0
    2   3.0
    r2rtNrvc
OsŽt|ƒr"|j|f|žd|i|—ŽSt|f|Ž\}}}}t|ƒ}t||||ƒ}    |     ¡}
t|ƒsh|
dk    rh|
S|r˜tt|
ƒ}
|
j    dd…|f}
tt|
ƒ}
||
_
|
dkrj|j j dkrÀ|j |f|ž|ŽS|sÈ|rÜ|j|f|ž|Ž}
nŽ|jdkrô| |¡}
|
St||gdid} z |  ¡}
Wn>tk
rP} zdt| ƒkr6‚| |¡}
W5d} ~ XYnXtt|
ƒ}
|jj
 ¡|
_
|jsŠ| |
¡}
tt|
ƒƒ|
_|
S)Nrxr{rK)rprqzNo objects to concatenate)r>r}r0r/r.rxr&rr2Úilocrƒr‰r‹rŒÚ_aggregate_framer¬rðrrˆrûr„rÎr<rÉrz) rVrorwrxrprqrrƒÚorderÚopr’ZgbarßrKrKrLr“êsTÿÿÿÿ
 
 
 
 
 
 
zDataFrameGroupBy.aggregatec s t ˆ¡‰‡‡‡fdd„}i}|jdkr:|j||jddSt| ¡ƒD]2\}}|j}|j     ||¡}    t
j ||d}
|    ||
<qF|sŒ| ||j¡S|  |¡} |  | ¡S)Ncsˆ|fˆžˆŽSrgrKr”r–rKrLr—5r˜z6DataFrameGroupBy._python_agg_general.<locals>.<lambda>rT©Zis_aggr¤)r†r™r‡rUr^r·rirRr‰ršr3r¸Ú_indexed_output_to_ndframer) rVrorprqr›rÁr¾rSrRr’r«rœrKr–rLrŒ3s
 
 
 
z$DataFrameGroupBy._python_agg_generalrerfccs\|j}|jdkr|j}t|tƒr4|j|jkr4|Vn$| ¡D]\}}||jkrPq<|Vq<dS©Nr{)r^r¬ÚTr~r=rRÚ
exclusionsr³)rVrSr¥r¹rKrKrLriLs
 
z DataFrameGroupBy._iterate_slicesc OsŽ|jjdkrtdƒ‚|j}i}|j ||j¡D] \}}||f|ž|Ž}|||<q.|jj}    |jd|j}
|jj    ||
|    d} |jdkrŠ| j
} | S)Nr{zNumber of keys must be 1©rzrƒr) r‰r‹r‚rˆrär¬rŠÚaxesrSrTr„) rVrorprqrSr’rRZgrp_dfZfresrŠZother_axr rKrKrLr~^s 
 
z!DataFrameGroupBy._aggregate_frameFrŸrZ)rÃr¹rÄrÅc    Cst|ƒdkrF|r|j}n|jj}|jj||jd}|j|jdd}|St    t
j |Ždƒ}|dkrh|j ¡St |t ƒr‚|j|||dS|jr|jjnd}t |tjtfƒr¸|jj|||jdSt |tƒsþ|jrÚ|jj||dS|jj||jgd}| |¡}|Sn| |||||¡SdS)    Nrr†FrúrÈrÛr|)rƒ)rÉrzr‰rŠrSrTrƒrÚdtypesÚnextr†Znot_noner~r2rÍr„rçZndarrayr9Z_constructor_slicedZ
_selectionr=rÎÚ_wrap_applied_output_series)    rVrÃr¹rÄrÅrÏr’Úfirst_not_noneÚ    key_indexrKrKrLrÐqsH 
 
ýÿ 
ûz%DataFrameGroupBy._wrap_applied_outputz list[Series]z Index | NonerÂ)r¹rÄrŒrÅrPc sø| ¡}tf|މ‡fdd„|Dƒ}tdd„|Dƒƒ}|sJ|j|d|dSt dd„|Dƒ¡}|jdkrª|}    |j ¡}
|
j    dkrºd    d
„|Dƒ} t
| ƒd krºt | ƒd|
_    n|j}    |}
|j }|j tkrÌ| ¡}|jj||    |
d } |jsî| | ¡} | | ¡S) Ncsg|]}|dk    r|nˆ‘qSrgrKr ©ÚbackuprKrLr£ºsz@DataFrameGroupBy._wrap_applied_output_series.<locals>.<listcomp>css|] }|jVqdSrgr|r rKrKrLr¢¼sz?DataFrameGroupBy._wrap_applied_output_series.<locals>.<genexpr>TrÈcSsg|]}t |¡‘qSrK)rçZasarray©r¡ÚvrKrKrLr£ÈsrcSsh|]
}|j’qSrKrQrrKrKrLÚ    <setcomp>Ïsz?DataFrameGroupBy._wrap_applied_output_series.<locals>.<setcomp>r{r†)Z_construct_axes_dictr=r;rÍrçZvstackr¬rzrûrRrÉrŸr„r`rÑÚtolistrSrTr„rÎrÊ) rVr¹rÄr‹rŒrÅrqZall_indexed_sameZstacked_valuesrzrƒr#r’rKrrLrаs6
ý
 
 
 
 
z,DataFrameGroupBy._wrap_applied_output_seriesrrr)rÚrYr¬rPc     sh|dks t‚ˆj|ˆd}dddœ‡‡‡fdd„ }| |¡}| d|jd¡ˆj |¡}ˆ |¡}|S)NrrXr)ÚbvaluesrPcsˆjjd|ˆdfˆŽS)NrÙr{)r‰rÜ)r“©rÚrqrVrKrLÚarr_funcósÿÿz4DataFrameGroupBy._cython_transform.<locals>.arr_funcr{)r‚rdZgrouped_reduceZset_axisr‡rSrTZ_maybe_transpose_result)    rVrÚrYr¬rqrOr•Zres_mgrr¿rKr”rLràás ÿ
 
z"DataFrameGroupBy._cython_transformc
Oszddlm}g}|j}|jj||jd}|j|f|ž|Ž\}}    zt|ƒ\}
} Wntk
rbYnzXt     
| d|
¡z|  ||    | ¡\} } Wn0t k
r¸}zd}t |ƒ|‚W5d}~XYnX| j dkrÜt|j| | ƒ} | | ¡|D]B\}
} | j dkrôqàt     
| d|
¡| | ƒ} t|j| | ƒ} | | ¡qà|jdkr6|jn|j}|jdkrLdnd}|||jdd}|j||dd    }| |¡S)
Nrr§rárRz3transform must return a scalar value for each groupr{F)r¬r$)r¬rû)rår¨rˆr‰rär¬Ú _define_pathsr‰Ú StopIterationrÑrÒÚ _choose_pathrðÚsizeÚ_wrap_transform_general_framerSrµrƒrzZreindexræ)rVrorprqr¨ZappliedrSÚgenÚ    fast_pathÚ    slow_pathrRrÔÚpathrœrßÚmsgZ concat_indexZ
other_axisrérKrKrLrês< 
 
 
 z#DataFrameGroupBy._transform_generala
    >>> df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
    ...                           'foo', 'bar'],
    ...                    'B' : ['one', 'one', 'two', 'three',
    ...                           'two', 'two'],
    ...                    'C' : [1, 5, 5, 2, 5, 5],
    ...                    'D' : [2.0, 5., 8., 1., 2., 9.]})
    >>> grouped = df.groupby('A')[['C', 'D']]
    >>> grouped.transform(lambda x: (x - x.mean()) / x.std())
            C         D
    0 -1.154701 -0.577350
    1  0.577350  0.000000
    2  0.577350  1.154701
    3 -1.154701 -1.000000
    4  0.577350 -0.577350
    5  0.577350  1.000000
 
    Broadcast result of the transformation
 
    >>> grouped.transform(lambda x: x.max() - x.min())
        C    D
    0  4.0  6.0
    1  3.0  8.0
    2  4.0  6.0
    3  3.0  8.0
    4  4.0  6.0
    5  3.0  8.0
 
    >>> grouped.transform("mean")
        C    D
    0  3.666667  4.0
    1  4.000000  5.0
    2  3.666667  4.0
    3  4.000000  5.0
    4  3.666667  4.0
    5  4.000000  5.0
 
    .. versionchanged:: 1.3.0
 
    The resulting dtype will reflect the return value of the passed ``func``,
    for example:
 
    >>> grouped.transform(lambda x: x.astype(int).max())
    C  D
    0  5  8
    1  5  9
    2  5  8
    3  5  9
    4  5  8
    5  5  9
    rÕcOs|j|f|ž||dœ|—ŽSrÖr×rØrKrKrLrÙbsÿÿÿÿzDataFrameGroupBy.transformcsXtˆtƒr.‡‡‡fdd„}‡‡‡‡fdd„}n"‡‡‡fdd„}‡‡‡‡fdd„}||fS)Ncst|ˆƒˆˆŽSrgrë©rÔr–rKrLr—kr˜z0DataFrameGroupBy._define_paths.<locals>.<lambda>cs|j‡‡‡fdd„ˆjdS)Ncst|ˆƒˆˆŽSrgrër”r–rKrLr—mr˜úBDataFrameGroupBy._define_paths.<locals>.<lambda>.<locals>.<lambda>rá©rnr¬r ©rprorqrVrKrLr—lsÿcsˆ|fˆžˆŽSrgrKr r–rKrLr—pr˜cs|j‡‡‡fdd„ˆjdS)Ncsˆ|fˆžˆŽSrgrKr”r–rKrLr—rr˜r¡rár¢r r£rKrLr—qsÿ)r~r)rVrorprqrœrrKr£rLr–is 
zDataFrameGroupBy._define_pathsr)rœrrÔcCs¾|}||ƒ}|jdkr||fSz ||ƒ}Wn0tk
r@‚Yntk
rZ||fYSXt|tƒr~|j |j¡s¨||fSn*t|tƒr |j |j¡s¨||fSn||fS| |¡r¶|}||fSrƒ)    r‡r‚Ú    Exceptionr~r2rƒÚequalsr=rz)rVrœrrÔržrœZres_fastrKrKrLr˜vs(
 
 
 
 
 
zDataFrameGroupBy._choose_pathTrÆc     OsÂg}|j}|jj||jd}|D]”\}}    t |    d|¡||    f|ž|Ž}
z |
 ¡}
Wntk
rfYnXt|
ƒs€t    |
ƒržt
|
ƒržt |
ƒr´|
r´|  |  |¡¡q tdt|
ƒj›dƒ‚q | ||¡S)a7
        Filter elements from groups that don't satisfy a criterion.
 
        Elements from groups are filtered if they do not satisfy the
        boolean criterion specified by func.
 
        Parameters
        ----------
        func : function
            Criterion to apply to each group. Should return True or False.
        dropna : bool
            Drop groups that do not pass the filter. True by default; if False,
            groups that evaluate False are filled with NaNs.
 
        Returns
        -------
        DataFrame
 
        Notes
        -----
        Each subframe is endowed the attribute 'name' in case you need to know
        which group you are working on.
 
        Functions that mutate the passed object can produce unexpected
        behavior or errors and are not supported. See :ref:`gotchas.udf-mutation`
        for more details.
 
        Examples
        --------
        >>> df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
        ...                           'foo', 'bar'],
        ...                    'B' : [1, 2, 3, 4, 5, 6],
        ...                    'C' : [2.0, 5., 8., 1., 2., 9.]})
        >>> grouped = df.groupby('A')
        >>> grouped.filter(lambda x: x['B'].mean() > 3.)
             A  B    C
        1  bar  2  5.0
        3  bar  4  1.0
        5  bar  6  9.0
        rárRzfilter function returned a z, but expected a scalar bool)r^r‰rär¬rÑrÒZsqueezeÚAttributeErrorr$r*r+r,rµrïrarbrFrñ) rVrorÇrprqròrSr›rRrÔrœrKrKrLrôšs")   ÿzDataFrameGroupBy.filterz DataFrameGroupBy | SeriesGroupBycs<|jdkrtdƒ‚t|tƒr0t|ƒdkr0tdƒ‚tƒ |¡S)Nr{z'Cannot subset columns when using axis=1zRCannot subset columns with a tuple with more than one element. Use a list instead.)r¬rðr~ržrÉrmÚ __getitem__)rVr«rrrKrLr§ßs
ÿzDataFrameGroupBy.__getitem__rO)ÚndimcCsœ|dkrJ|dkr|j}t||j|j|j|j|j||j|j|j|j    |j
d S|dkr|dkrd|j|}t ||j|j|j||j|j|j|j    |j
d
St dƒ‚dS)a
        sub-classes to define
        return a sliced object
 
        Parameters
        ----------
        key : string / list of selections
        ndim : {1, 2}
            requested ndim of result
        subset : object, default None
            subset to act on
        éN)
r¬Úlevelr‰r…Ú    selectionr„r÷Ú
group_keysrÌrÇr{)    rªr‰r…r«r„r÷r¬rÌrÇzinvalid ndim for _gotitem) rSr|r‰r¬rªr…r„r÷r¬rÌrÇrMr‚)rVr«r¨ÚsubsetrKrKrLÚ_gotitemísB ô
ö zDataFrameGroupBy._gotitemrXr[rr\cCs4|j}|jdkr|jj}n|j}|r0|jdd}|S)Nr{Frú)rˆr¬r„r_Zget_numeric_data)rVrYrRrSrOrKrKrLrds
 
 z'DataFrameGroupBy._get_data_to_aggregatez"Mapping[base.OutputKey, ArrayLike])rÁrPcCsTdd„| ¡Dƒ}tdd„|Dƒƒ}| |j d|j¡j¡|j |¡}||_    |S)zQ
        Wrap the dict result of a GroupBy aggregation into a DataFrame.
        cSsi|]\}}|j|“qSrKr®r¯rKrKrLr±0sz?DataFrameGroupBy._indexed_output_to_ndframe.<locals>.<dictcomp>cSsg|]
}|j‘qSrKr©rªrKrKrLr£1sz?DataFrameGroupBy._indexed_output_to_ndframe.<locals>.<listcomp>r{)
r³r9Z
_set_namesrˆZ    _get_axisr¬r#rSrTrƒ)rVrÁrÀrƒr’rKrKrLr‚*s  z+DataFrameGroupBy._indexed_output_to_ndframerNcCs |j |¡Srg)rSrTrUrKrKrLrW8sz$DataFrameGroupBy._wrap_agged_manager©rSc    csDt|jƒD]4\}}|t|jdd…|f||j|j|jdfVq
dS)N)r«r‰r…rÌ)r·rƒrMr}r‰r…rÌ)rVrSÚiZcolnamerKrKrLÚ_iterate_column_groupbys;sûz)DataFrameGroupBy._iterate_column_groupbys)rSrPcsVddlm}|j}‡fdd„| |¡Dƒ}t|ƒsDtg||jjdS|||ddSdS)Nrr§csg|]\}}ˆ|ƒ‘qSrKrK)r¡rZ col_groupby©rorKrLr£Isz>DataFrameGroupBy._apply_to_column_groupbys.<locals>.<listcomp>©rƒrzr{)r­r¬)rår¨rƒr±rÉr2r‰rŠ)rVrorSr¨rƒr½rKr²rLÚ_apply_to_column_groupbysEs 
ÿz*DataFrameGroupBy._apply_to_column_groupbysrõcsb|jdkr$|j‡fdd„|jddS|j}|j‡fdd„|d}|js^tt|ƒƒ|_| |¡}|S)aÍ
        Return DataFrame with counts of unique elements in each position.
 
        Parameters
        ----------
        dropna : bool, default True
            Don't include NaN in the counts.
 
        Returns
        -------
        nunique: DataFrame
 
        Examples
        --------
        >>> df = pd.DataFrame({'id': ['spam', 'egg', 'egg', 'spam',
        ...                           'ham', 'ham'],
        ...                    'value1': [1, 5, 5, 2, 5, 5],
        ...                    'value2': list('abbaxy')})
        >>> df
             id  value1 value2
        0  spam       1      a
        1   egg       5      b
        2   egg       5      b
        3  spam       2      a
        4   ham       5      x
        5   ham       5      y
 
        >>> df.groupby('id').nunique()
              value1  value2
        id
        egg        1       1
        ham        1       2
        spam       2       1
 
        Check for rows with the same id but conflicting values:
 
        >>> df.groupby('id').filter(lambda g: (g.nunique() > 1).any())
             id  value1 value2
        0  spam       1      a
        3  spam       2      a
        4   ham       5      x
        5   ham       5      y
        rcs
| ˆ¡Srg©r©ZsgbrÆrKrLr—ƒr˜z*DataFrameGroupBy.nunique.<locals>.<lambda>Trcs
| ˆ¡Srgrµr¶rÆrKrLr—ˆr˜r¯)    r¬rUrˆr´r„r<rÉrzrÎ)rVrÇrSr½rKrÆrLrSs-
 
ÿ
ÿ
zDataFrameGroupBy.nuniquer7rEcs:ˆdkr|j‰‡‡‡fdd„}d|_|j||jdd}|S)a#
        Return index of first occurrence of maximum over requested axis.
 
        NA/null values are excluded.
 
        Parameters
        ----------
        axis : {{0 or 'index', 1 or 'columns'}}, default None
            The axis to use. 0 or 'index' for row-wise, 1 or 'columns' for column-wise.
            If axis is not provided, grouper's axis is used.
 
            .. versionchanged:: 2.0.0
 
        skipna : bool, default True
            Exclude NA/null values. If an entire row/column is NA, the result
            will be NA.
        numeric_only : bool, default False
            Include only `float`, `int` or `boolean` data.
 
            .. versionadded:: 1.5.0
 
        Returns
        -------
        Series
            Indexes of maxima along the specified axis.
 
        Raises
        ------
        ValueError
            * If the row/column is empty
 
        See Also
        --------
        Series.idxmax : Return index of the maximum element.
 
        Notes
        -----
        This method is the DataFrame version of ``ndarray.argmax``.
 
        Examples
        --------
        Consider a dataset containing food consumption in Argentina.
 
        >>> df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48],
        ...                    'co2_emissions': [37.2, 19.66, 1712]},
        ...                    index=['Pork', 'Wheat Products', 'Beef'])
 
        >>> df
                        consumption  co2_emissions
        Pork                  10.51         37.20
        Wheat Products       103.11         19.66
        Beef                  55.48       1712.00
 
        By default, it returns the index for the maximum value in each column.
 
        >>> df.idxmax()
        consumption     Wheat Products
        co2_emissions             Beef
        dtype: object
 
        To return the index for the maximum value in each row, use ``axis="columns"``.
 
        >>> df.idxmax(axis="columns")
        Pork              co2_emissions
        Wheat Products     consumption
        Beef              co2_emissions
        dtype: object
        Ncs|jˆˆˆdS©NrH)r[©Zdf©r¬rYrFrKrLroÞsz%DataFrameGroupBy.idxmax.<locals>.funcr[TrS©r¬rFrUrˆ©rVr¬rFrYror’rKr¹rLr[‘sJÿzDataFrameGroupBy.idxmaxcs:ˆdkr|j‰‡‡‡fdd„}d|_|j||jdd}|S)a&
        Return index of first occurrence of minimum over requested axis.
 
        NA/null values are excluded.
 
        Parameters
        ----------
        axis : {{0 or 'index', 1 or 'columns'}}, default None
            The axis to use. 0 or 'index' for row-wise, 1 or 'columns' for column-wise.
            If axis is not provided, grouper's axis is used.
 
            .. versionchanged:: 2.0.0
 
        skipna : bool, default True
            Exclude NA/null values. If an entire row/column is NA, the result
            will be NA.
        numeric_only : bool, default False
            Include only `float`, `int` or `boolean` data.
 
            .. versionadded:: 1.5.0
 
        Returns
        -------
        Series
            Indexes of minima along the specified axis.
 
        Raises
        ------
        ValueError
            * If the row/column is empty
 
        See Also
        --------
        Series.idxmin : Return index of the minimum element.
 
        Notes
        -----
        This method is the DataFrame version of ``ndarray.argmin``.
 
        Examples
        --------
        Consider a dataset containing food consumption in Argentina.
 
        >>> df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48],
        ...                    'co2_emissions': [37.2, 19.66, 1712]},
        ...                    index=['Pork', 'Wheat Products', 'Beef'])
 
        >>> df
                        consumption  co2_emissions
        Pork                  10.51         37.20
        Wheat Products       103.11         19.66
        Beef                  55.48       1712.00
 
        By default, it returns the index for the minimum value in each column.
 
        >>> df.idxmin()
        consumption                Pork
        co2_emissions    Wheat Products
        dtype: object
 
        To return the index for the minimum value in each row, use ``axis="columns"``.
 
        >>> df.idxmin(axis="columns")
        Pork                consumption
        Wheat Products    co2_emissions
        Beef                consumption
        dtype: object
        Ncs|jˆˆˆdSr·)rXr¸r¹rKrLro4sz%DataFrameGroupBy.idxmin.<locals>.funcrXTrSrºr»rKr¹rLrXçsJÿzDataFrameGroupBy.idxminzSequence[Hashable] | None)r­rr÷rrÇrPcCs| |||||¡S)u'
        Return a Series or DataFrame containing counts of unique rows.
 
        .. versionadded:: 1.4.0
 
        Parameters
        ----------
        subset : list-like, optional
            Columns to use when counting unique combinations.
        normalize : bool, default False
            Return proportions rather than frequencies.
        sort : bool, default True
            Sort by frequencies.
        ascending : bool, default False
            Sort in ascending order.
        dropna : bool, default True
            Don’t include counts of rows that contain NA values.
 
        Returns
        -------
        Series or DataFrame
            Series if the groupby as_index is True, otherwise DataFrame.
 
        See Also
        --------
        Series.value_counts: Equivalent method on Series.
        DataFrame.value_counts: Equivalent method on DataFrame.
        SeriesGroupBy.value_counts: Equivalent method on SeriesGroupBy.
 
        Notes
        -----
        - If the groupby as_index is True then the returned Series will have a
          MultiIndex with one level per input column.
        - If the groupby as_index is False then the returned DataFrame will have an
          additional column with the value_counts. The column is labelled 'count' or
          'proportion', depending on the ``normalize`` parameter.
 
        By default, rows that contain any NA values are omitted from
        the result.
 
        By default, the result will be in descending order so that the
        first element of each group is the most frequently-occurring row.
 
        Examples
        --------
        >>> df = pd.DataFrame({
        ...    'gender': ['male', 'male', 'female', 'male', 'female', 'male'],
        ...    'education': ['low', 'medium', 'high', 'low', 'high', 'low'],
        ...    'country': ['US', 'FR', 'US', 'FR', 'FR', 'FR']
        ... })
 
        >>> df
                gender  education   country
        0       male    low         US
        1       male    medium      FR
        2       female  high        US
        3       male    low         FR
        4       female  high        FR
        5       male    low         FR
 
        >>> df.groupby('gender').value_counts()
        gender  education  country
        female  high       FR         1
                           US         1
        male    low        FR         2
                           US         1
                medium     FR         1
        Name: count, dtype: int64
 
        >>> df.groupby('gender').value_counts(ascending=True)
        gender  education  country
        female  high       FR         1
                           US         1
        male    low        US         1
                medium     FR         1
                low        FR         2
        Name: count, dtype: int64
 
        >>> df.groupby('gender').value_counts(normalize=True)
        gender  education  country
        female  high       FR         0.50
                           US         0.50
        male    low        FR         0.50
                           US         0.25
                medium     FR         0.25
        Name: proportion, dtype: float64
 
        >>> df.groupby('gender', as_index=False).value_counts()
           gender education country  count
        0  female      high      FR      1
        1  female      high      US      1
        2    male       low      FR      2
        3    male       low      US      1
        4    male    medium      FR      1
 
        >>> df.groupby('gender', as_index=False).value_counts(normalize=True)
           gender education country  proportion
        0  female      high      FR        0.50
        1  female      high      US        0.50
        2    male       low      FR        0.50
        3    male       low      US        0.25
        4    male    medium      FR        0.25
        )r%)rVr­rr÷rrÇrKrKrLr'?sozDataFrameGroupBy.value_countsz'Hashable | Mapping | Series | DataFramer6zDataFrame | None)r9r:r¬r;rPc    Cs|jd||||||d}|S)aÈ
        Fill NA/NaN values using the specified method within groups.
 
        Parameters
        ----------
        value : scalar, dict, Series, or DataFrame
            Value to use to fill holes (e.g. 0), alternately a
            dict/Series/DataFrame of values specifying which value to use for
            each index (for a Series) or column (for a DataFrame).  Values not
            in the dict/Series/DataFrame will not be filled. This value cannot
            be a list. Users wanting to use the ``value`` argument and not ``method``
            should prefer :meth:`.DataFrame.fillna` as this
            will produce the same result and be more performant.
        method : {{'bfill', 'ffill', None}}, default None
            Method to use for filling holes. ``'ffill'`` will propagate
            the last valid observation forward within a group.
            ``'bfill'`` will use next valid observation to fill the gap.
        axis : {0 or 'index', 1 or 'columns'}
            Axis along which to fill missing values. When the :class:`DataFrameGroupBy`
            ``axis`` argument is ``0``, using ``axis=1`` here will produce
            the same results as :meth:`.DataFrame.fillna`. When the
            :class:`DataFrameGroupBy` ``axis`` argument is ``1``, using ``axis=0``
            or ``axis=1`` here will produce the same results.
        inplace : bool, default False
            Broken. Do not set to True.
        limit : int, default None
            If method is specified, this is the maximum number of consecutive
            NaN values to forward/backward fill within a group. In other words,
            if there is a gap with more than this number of consecutive NaNs,
            it will only be partially filled. If method is not specified, this is the
            maximum number of entries along the entire axis where NaNs will be
            filled. Must be greater than 0 if not None.
        downcast : dict, default is None
            A dict of item->dtype of what to downcast if possible,
            or the string 'infer' which will try to downcast to an appropriate
            equal type (e.g. float64 to int64 if possible).
 
        Returns
        -------
        DataFrame
            Object with missing values filled.
 
        See Also
        --------
        ffill : Forward fill values within a group.
        bfill : Backward fill values within a group.
 
        Examples
        --------
        >>> df = pd.DataFrame(
        ...     {
        ...         "key": [0, 0, 1, 1, 1],
        ...         "A": [np.nan, 2, np.nan, 3, np.nan],
        ...         "B": [2, 3, np.nan, np.nan, np.nan],
        ...         "C": [np.nan, np.nan, 2, np.nan, np.nan],
        ...     }
        ... )
        >>> df
           key    A    B   C
        0    0  NaN  2.0 NaN
        1    0  2.0  3.0 NaN
        2    1  NaN  NaN 2.0
        3    1  3.0  NaN NaN
        4    1  NaN  NaN NaN
 
        Propagate non-null values forward or backward within each group along columns.
 
        >>> df.groupby("key").fillna(method="ffill")
             A    B   C
        0  NaN  2.0 NaN
        1  2.0  3.0 NaN
        2  NaN  NaN 2.0
        3  3.0  NaN 2.0
        4  3.0  NaN 2.0
 
        >>> df.groupby("key").fillna(method="bfill")
             A    B   C
        0  2.0  2.0 NaN
        1  2.0  3.0 NaN
        2  3.0  NaN 2.0
        3  3.0  NaN NaN
        4  NaN  NaN NaN
 
        Propagate non-null values forward or backward within each group along rows.
 
        >>> df.groupby([0, 0, 1, 1], axis=1).fillna(method="ffill")
           key    A    B    C
        0  0.0  0.0  2.0  2.0
        1  0.0  2.0  3.0  3.0
        2  1.0  1.0  NaN  2.0
        3  1.0  3.0  NaN  NaN
        4  1.0  1.0  NaN  NaN
 
        >>> df.groupby([0, 0, 1, 1], axis=1).fillna(method="bfill")
           key    A    B    C
        0  0.0  NaN  2.0  NaN
        1  0.0  2.0  3.0  NaN
        2  1.0  NaN  2.0  2.0
        3  1.0  3.0  NaN  NaN
        4  1.0  NaN  NaN  NaN
 
        Only replace the first NaN element within a group along rows.
 
        >>> df.groupby("key").fillna(method="ffill", limit=1)
             A    B    C
        0  NaN  2.0  NaN
        1  2.0  3.0  NaN
        2  NaN  NaN  2.0
        3  3.0  NaN  2.0
        4  3.0  NaN  NaN
        r>r?r@rArKrKrLr>°sxù    zDataFrameGroupBy.fillnarrBcKs|jd||dœ|—Ž}|S)ae
        Return the elements in the given *positional* indices in each group.
 
        This means that we are not indexing according to actual values in
        the index attribute of the object. We are indexing according to the
        actual position of the element in the object.
 
        If a requested index does not exist for some group, this method will raise.
        To get similar behavior that ignores indices that don't exist, see
        :meth:`.DataFrameGroupBy.nth`.
 
        Parameters
        ----------
        indices : array-like
            An array of ints indicating which positions to take.
        axis : {0 or 'index', 1 or 'columns', None}, default 0
            The axis on which to select elements. ``0`` means that we are
            selecting rows, ``1`` means that we are selecting columns.
        **kwargs
            For compatibility with :meth:`numpy.take`. Has no effect on the
            output.
 
        Returns
        -------
        DataFrame
            An DataFrame containing the elements taken from each group.
 
        See Also
        --------
        DataFrame.take : Take elements from a Series along an axis.
        DataFrame.loc : Select a subset of a DataFrame by labels.
        DataFrame.iloc : Select a subset of a DataFrame by positions.
        numpy.take : Take elements from an array along an axis.
 
        Examples
        --------
        >>> df = pd.DataFrame([('falcon', 'bird', 389.0),
        ...                    ('parrot', 'bird', 24.0),
        ...                    ('lion', 'mammal', 80.5),
        ...                    ('monkey', 'mammal', np.nan),
        ...                    ('rabbit', 'mammal', 15.0)],
        ...                   columns=['name', 'class', 'max_speed'],
        ...                   index=[4, 3, 2, 1, 0])
        >>> df
             name   class  max_speed
        4  falcon    bird      389.0
        3  parrot    bird       24.0
        2    lion  mammal       80.5
        1  monkey  mammal        NaN
        0  rabbit  mammal       15.0
        >>> gb = df.groupby([1, 1, 2, 2, 2])
 
        Take elements at positions 0 and 1 along the axis 0 (default).
 
        Note how the indices selected in the result do not correspond to
        our input indices 0 and 1. That's because we are selecting the 0th
        and 1st rows, not rows whose indices equal 0 and 1.
 
        >>> gb.take([0, 1])
               name   class  max_speed
        1 4  falcon    bird      389.0
          3  parrot    bird       24.0
        2 2    lion  mammal       80.5
          1  monkey  mammal        NaN
 
        The order of the specified indices influences the order in the result.
        Here, the order is swapped from the previous example.
 
        >>> gb.take([1, 0])
               name   class  max_speed
        1 3  parrot    bird       24.0
          4  falcon    bird      389.0
        2 1  monkey  mammal        NaN
          2    lion  mammal       80.5
 
        Take elements at indices 1 and 2 along the axis 1 (column selection).
 
        We may take elements using negative integers for positive indices,
        starting from the end of the object, just like with Python lists.
 
        >>> gb.take([-1, -2])
               name   class  max_speed
        1 3  parrot    bird       24.0
          4  falcon    bird      389.0
        2 0  rabbit  mammal       15.0
          1  monkey  mammal        NaN
        r)rC)r)r@rDrKrKrLr)3    s]zDataFrameGroupBy.takezAxis | None | lib.NoDefaultcKs|jd|||dœ|—Ž}|S)at
        Return unbiased skew within groups.
 
        Normalized by N-1.
 
        Parameters
        ----------
        axis : {0 or 'index', 1 or 'columns', None}, default 0
            Axis for the function to be applied on.
 
            Specifying ``axis=None`` will apply the aggregation across both axes.
 
            .. versionadded:: 2.0.0
 
        skipna : bool, default True
            Exclude NA/null values when computing the result.
 
        numeric_only : bool, default False
            Include only float, int, boolean columns.
 
        **kwargs
            Additional keyword arguments to be passed to the function.
 
        Returns
        -------
        DataFrame
 
        See Also
        --------
        DataFrame.skew : Return unbiased skew over requested axis.
 
        Examples
        --------
        >>> arrays = [['falcon', 'parrot', 'cockatoo', 'kiwi',
        ...            'lion', 'monkey', 'rabbit'],
        ...           ['bird', 'bird', 'bird', 'bird',
        ...            'mammal', 'mammal', 'mammal']]
        >>> index = pd.MultiIndex.from_arrays(arrays, names=('name', 'class'))
        >>> df = pd.DataFrame({'max_speed': [389.0, 24.0, 70.0, np.nan,
        ...                                  80.5, 21.5, 15.0]},
        ...                   index=index)
        >>> df
                        max_speed
        name     class
        falcon   bird        389.0
        parrot   bird         24.0
        cockatoo bird         70.0
        kiwi     bird          NaN
        lion     mammal       80.5
        monkey   mammal       21.5
        rabbit   mammal       15.0
        >>> gb = df.groupby(["class"])
        >>> gb.skew()
                max_speed
        class
        bird     1.628296
        mammal   1.669046
        >>> gb.skew(skipna=False)
                max_speed
        class
        bird          NaN
        mammal   1.669046
        rGrH)rGr@rIrKrKrLrG“    sFÿüûzDataFrameGroupBy.skewr5cCs t|ƒ}|SrgrJrKrKrKrLrLâ    szDataFrameGroupBy.plotr\r{z/str | Callable[[np.ndarray, np.ndarray], float])r:r^rYrPcCs|jd|||d}|S)Nr_)r:r^rYr@)rVr:r^rYr’rKrKrLr_è    sÿzDataFrameGroupBy.corrr8)r^r`rYrPcCs|jd|||d}|S)Nra)r^r`rYr@)rVr^r`rYr’rKrKrLraô    sÿzDataFrameGroupBy.covrfrrgrhri) rDrjrkrlrmrnÚsharexÚshareyroÚlayoutrrprqcKs4|jd|||||||||    |
| | | ||dœ|—Ž}|S)Nrr)rDrsrjrkrlrmrnrtr¼r½ror¾rrprq)rrr@)rVrDrsrjrkrlrmrnrtr¼r½ror¾rrprqrqr’rKrKrLrr
s,ÿðïzDataFrameGroupBy.histr=cCs| dd„¡S)NcSs|jSrg)rˆr¸rKrKrLr—-
r˜z)DataFrameGroupBy.dtypes.<locals>.<lambda>rdrhrKrKrLrˆ)
szDataFrameGroupBy.dtypesrr)r]r¬Údropr:rYrPcCs|jd|||||d}|S)NÚcorrwith)r]r¬r¿r:rYr@)rVr]r¬r¿r:rYr’rKrKrLrÀ/
s    úzDataFrameGroupBy.corrwith)N)FF)Fr)T)N)T)NTF)NTF)NFTFT)NNNFNN)r)r\r{F)Nr{F)NNTNNNNNFFNNrfNF)rFr\F)4rFrGrHrrvr"r6r“rxrŒrir~rÐrŠràrêZ)_DataFrameGroupBy__examples_dataframe_docr!r r8rÙr–r˜rôr§r®rdr‚rWr±r´rr[rXr?Zboxplotr'r>r)rryrGrzr2rLrIr_rarrrˆrÀr{rKrKrrrLr|ŒsÐÿ] Fû?4ü +ÿ6
 $E1ÿ 
@üXüVúsùýbüO
 
ü
ü
ð*(
 
úr|r2rÂ)rSrÔrœrPcCs¶ddlm}t|tƒrˆ|j |j¡rN||gt|jƒdd}|j|_|j|_n(|jt     
|j t|jƒdf¡|j|jd}t|t ƒs„t ‚|St|t ƒr®|j |j¡s®| |¡dS|SdS)Nrr§r{rár³)rºr¨r~r=rzÚis_rÉrƒrTrçr/r¹r2r‚Z _align_frame)rSrÔrœr¨Z    res_framerKrKrLršC
s  
 
ýrš)erIÚ
__future__rÚ collectionsrÚ    functoolsrÚtextwraprÚtypingrrrr    r
r r r rrrrÚnumpyrçZ pandas._libsrrrrÓZpandas._typingrrrrrrrrrrZ pandas.errorsrZpandas.util._decoratorsr r!r"Zpandas.core.dtypes.commonr#r$r%r&r'r(r)r*Zpandas.core.dtypes.missingr+r,Z pandas.corer-Zpandas.core.applyr.r/r0r1Zpandas.core.commonÚcoreÚcommonr†Zpandas.core.framer2Zpandas.core.groupbyr3Zpandas.core.groupby.groupbyr4r5r6r7r8Zpandas.core.indexes.apir9r:r;r<Zpandas.core.seriesr=Zpandas.core.util.numba_r>Zpandas.plottingr?rºr@Zpandas.core.genericrArrErBrCrMr|ršrKrKrKrLÚ<module>sd    80 (
            B