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
U
¬ý°dª¦ã@sôUdZddlmZddlZddlmZmZmZmZm    Z    m
Z
m Z m Z m Z mZddlZddlmZddlmZddlmZmZmZmZmZmZmZddlmZdd    lm Z!dd
l"m#Z#dd l$m%Z%m&Z&dd l'm(Z(dd l)m*Z*m+Z+m,Z,m-Z-m.Z.ddl/m0Z0m1Z1m2Z2ddl3m4Z4m5Z5ddl6m7Z7m8Z8m9Z9ddl:m;Z;ddl<m=Z=ddl>m?Z?ddl@mAZAmBZBerˆddlmCZCmDZDmEZEmFZFddlGmHZHmIZImJZJiZKdeLd<dddddœZMe dddZNGdd„de;ƒZOGd d!„d!ƒZPGd"d#„d#eeƒZQGd$d„de=ƒZRdS)%z.
Base and utility classes for pandas objects.
é)Ú annotationsN)
Ú TYPE_CHECKINGÚAnyÚGenericÚHashableÚIteratorÚLiteralÚTypeVarÚcastÚfinalÚoverload)Úusing_copy_on_write)Úlib)ÚAxisÚAxisIntÚDtypeObjÚ
IndexLabelÚNDFrameTÚShapeÚnpt)ÚPYPY)Úfunction©ÚAbstractMethodError)Úcache_readonlyÚdoc)Úcan_hold_element)Úis_categorical_dtypeÚ is_dict_likeÚis_extension_array_dtypeÚis_object_dtypeÚ    is_scalar)Ú ABCDataFrameÚABCIndexÚ    ABCSeries)ÚisnaÚremove_na_arraylike)Ú
algorithmsÚnanopsÚops)Ú DirNamesMixin)ÚOpsMixin)ÚExtensionArray)Úensure_wrapped_if_datetimelikeÚ extract_array)ÚDropKeepÚ NumpySorterÚNumpyValueArrayLikeÚ ScalarLike_co)Ú CategoricalÚIndexÚSerieszdict[str, str]Ú _shared_docsÚ IndexOpsMixinÚ)ÚklassZinplaceÚuniqueÚ
duplicatedÚ_T)Úboundcs\eZdZUdZded<edd„ƒZddœdd    „Zdd d d œdd„Zddœ‡fdd„ Z    ‡Z
S)Ú PandasObjectz/
    Baseclass for various pandas objects.
    zdict[str, Any]Ú_cachecCst|ƒS)zJ
        Class constructor (for this class it's just `__class__`.
        )Útype©Úself©rCúGd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/base.pyÚ _constructorlszPandasObject._constructorÚstr©ÚreturncCs
t |¡S)zI
        Return a string representation for a particular object.
        )ÚobjectÚ__repr__rArCrCrDrJsszPandasObject.__repr__Nz
str | NoneÚNone©ÚkeyrHcCs4t|dƒsdS|dkr"|j ¡n|j |d¡dS)zV
        Reset cached properties. If ``key`` is passed, only clears that key.
        r?N)Úhasattrr?ÚclearÚpop)rBrMrCrCrDÚ _reset_cachezs
 
 zPandasObject._reset_cacheÚintcs<t|ddƒ}|r2|dd}tt|ƒr(|n| ¡ƒStƒ ¡S)zx
        Generates the total memory usage for an object that returns
        either a value or Series of values
        Ú memory_usageNT©Údeep)ÚgetattrrRr!ÚsumÚsuperÚ
__sizeof__)rBrSZmem©Ú    __class__rCrDrY…s
 
zPandasObject.__sizeof__)N) Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú__annotations__ÚpropertyrErJrQrYÚ __classcell__rCrCrZrDr>ds
 
 r>c@s.eZdZdZddœdd„Zdddœdd    „Zd
S) ÚNoNewAttributesMixina„
    Mixin which prevents adding new attributes.
 
    Prevents additional attributes via xxx.attribute = "something" after a
    call to `self.__freeze()`. Mainly used to prevent the user from using
    wrong attributes on an accessor (`Series.cat/.str/.dt`).
 
    If you really want to add a new attribute at a later time, you need to use
    `object.__setattr__(self, key, value)`.
    rKrGcCst |dd¡dS)z9
        Prevents setting additional attributes.
        Ú__frozenTN)rIÚ __setattr__rArCrCrDÚ_freezeŸszNoNewAttributesMixin._freezerFrLcCsTt|ddƒrB|dksB|t|ƒjksBt||dƒdk    sBtd|›dƒ‚t |||¡dS)NrdFr?z"You cannot add any new attribute 'ú')rVr@Ú__dict__ÚAttributeErrorrIre)rBrMÚvaluerCrCrDre¦s ÿ þýz NoNewAttributesMixin.__setattr__N)r\r]r^r_rfrerCrCrCrDrc“s rcc@s¤eZdZUdZded<dZded<ded<d    d
gZeeƒZe    e
d d „ƒƒZ e d d„ƒZ e    e ddœdd„ƒƒZe    e dd„ƒƒZdd„Zdddœdd„Zdd„ZeZdS)ÚSelectionMixinz‰
    mixin implementing the selection & aggregation interface on a group-like
    object sub-classes need to define: obj, exclusions
    rÚobjNzIndexLabel | NoneÚ
_selectionzfrozenset[Hashable]Ú
exclusionsr?Ú __setstate__cCs&t|jtttttjfƒs |jgS|jS©N)Ú
isinstancermÚlistÚtupler$r#ÚnpÚndarrayrArCrCrDÚ_selection_listÁs ÿzSelectionMixin._selection_listcCs,|jdkst|jtƒr|jS|j|jSdSrp)rmrqrlr$rArCrCrDÚ _selected_objÊszSelectionMixin._selected_objrRrGcCs|jjSrp)rwÚndimrArCrCrDrxÑszSelectionMixin.ndimcCsVt|jtƒr|jS|jdk    r*|j |j¡St|jƒdkrL|jj|jdddS|jSdS)NréT)ÚaxisZ
only_slice)    rqrlr$rmZ_getitem_nocopyrvÚlenrnZ
_drop_axisrArCrCrDÚ_obj_with_exclusionsÖs 
z#SelectionMixin._obj_with_exclusionscCsÈ|jdk    rtd|j›dƒ‚t|tttttjfƒr’t    |j
j   |¡ƒt    t |ƒƒkr€tt |ƒ |j
j ¡ƒ}tdt|ƒdd…›ƒ‚|jt|ƒddS||j
krªtd|›ƒ‚|j
|j}|j||dSdS)    Nz
Column(s) z already selectedzColumns not found: ryéÿÿÿÿé©rxzColumn not found: )rmÚ
IndexErrorrqrrrsr$r#rtrur{rlÚcolumnsÚ intersectionÚsetÚ
differenceÚKeyErrorrFÚ_gotitemrx)rBrMÚbad_keysrxrCrCrDÚ __getitem__ès
 
 zSelectionMixin.__getitem__rcCs t|ƒ‚dS)a
        sub-classes to define
        return a sliced object
 
        Parameters
        ----------
        key : str / list of selections
        ndim : {1, 2}
            requested ndim of result
        subset : object, default None
            subset to act on
        Nr)rBrMrxZsubsetrCrCrDr†øs zSelectionMixin._gotitemcOs t|ƒ‚dSrpr)rBÚfuncÚargsÚkwargsrCrCrDÚ    aggregateszSelectionMixin.aggregate)N)r\r]r^r_r`rmZ_internal_namesrƒZ_internal_names_setr rarvrrwrxr|rˆr†rŒZaggrCrCrCrDrkµs*
 
 rkc@s8eZdZUdZdZedgƒZded<eddœdd    „ƒZ    ed
dœd d „ƒZ
e d d dœdd„ƒZ ee ddZ eddœdd„ƒZddœdd„Zeddœdd„ƒZe dd„ƒZeddœdd„ƒZeddœd d!„ƒZed"dœd#d$„ƒZe d%d&ejfd'd(d)d*d+œd,d-„ƒZe ed(dœd.d/„ƒƒZdŒd1d(d2œd3d4„Zed5d6d7d8dd1d(dd9œd:d;„ƒZdŽd1d(d2œd<d=„Zeed6d5d>d8dd1d(dd9œd?d@„ƒZdAdB„ZeZdCdœdDdE„Z e!d(dœdFdG„ƒZ"dHdœdIdJ„Z#dKd0d%d%dLœdMdNd(dOœdPdQ„Z$e ddRdS„ƒZ%e d‘d(d(d(d(dTdUœdVdW„ƒZ&dXdY„Z'e d’d(ddZœd[d\„ƒZ(ed(dœd]d^„ƒZ)ed(dœd_d`„ƒZ*ed(dœdadb„ƒZ+e d“d(ddcœddde„ƒZ,ee-j.dfdfdfe/ 0dg¡dhd”d(d(didjœdkdl„ƒZ.dme1dn<e2d•dpdqdrdsdtœdudv„ƒZ3e2d–dwdqdrdxdtœdydv„ƒZ3ee1dndzd{d—d}dqdrd~dtœddv„ƒZ3d€dœd‚dœdƒd„„Z4e d˜d‚dHd…œd†d‡„ƒZ5dˆd‰„Z6dŠd‹„Z7d%S)™r7zS
    Common ops mixin to support a unified interface / docs for Series / Index
    ièÚtolistzfrozenset[str]Ú _hidden_attrsrrGcCs t|ƒ‚dSrprrArCrCrDÚdtypeszIndexOpsMixin.dtypezExtensionArray | np.ndarraycCs t|ƒ‚dSrprrArCrCrDÚ_valuesszIndexOpsMixin._valuesr<)rBrHcOst ||¡|S)zw
        Return the transpose, which is by definition self.
 
        Returns
        -------
        %(klass)s
        )ÚnvZvalidate_transpose)rBrŠr‹rCrCrDÚ    transpose"s     zIndexOpsMixin.transposezD
        Return the transpose, which is by definition self.
        )rrcCs|jjS)z®
        Return a tuple of the shape of the underlying data.
 
        Examples
        --------
        >>> s = pd.Series([1, 2, 3])
        >>> s.shape
        (3,)
        )rÚshaperArCrCrDr“5s zIndexOpsMixin.shaperRcCs t|ƒ‚dSrprrArCrCrDÚ__len__BszIndexOpsMixin.__len__z
Literal[1]cCsdS)zO
        Number of dimensions of the underlying data, by definition 1.
        ryrCrArCrCrDrxFszIndexOpsMixin.ndimcCs$t|ƒdkrtt|ƒƒStdƒ‚dS)a 
        Return the first element of the underlying data as a Python scalar.
 
        Returns
        -------
        scalar
            The first element of %(klass)s.
 
        Raises
        ------
        ValueError
            If the data is not length-1.
        ryz6can only convert an array of size 1 to a Python scalarN)r{ÚnextÚiterÚ
ValueErrorrArCrCrDÚitemMs  zIndexOpsMixin.itemcCs|jjS)zD
        Return the number of bytes in the underlying data.
        )rÚnbytesrArCrCrDr™`szIndexOpsMixin.nbytescCs
t|jƒS)zG
        Return the number of elements in the underlying data.
        )r{rrArCrCrDÚsizegszIndexOpsMixin.sizer,cCs t|ƒ‚dS)aM
        The ExtensionArray of the data backing this Series or Index.
 
        Returns
        -------
        ExtensionArray
            An ExtensionArray of the values stored within. For extension
            types, this is the actual array. For NumPy native types, this
            is a thin (no copy) wrapper around :class:`numpy.ndarray`.
 
            ``.array`` differs ``.values`` which may require converting the
            data to a different form.
 
        See Also
        --------
        Index.to_numpy : Similar method that always returns a NumPy array.
        Series.to_numpy : Similar method that always returns a NumPy array.
 
        Notes
        -----
        This table lays out the different array types for each extension
        dtype within pandas.
 
        ================== =============================
        dtype              array type
        ================== =============================
        category           Categorical
        period             PeriodArray
        interval           IntervalArray
        IntegerNA          IntegerArray
        string             StringArray
        boolean            BooleanArray
        datetime64[ns, tz] DatetimeArray
        ================== =============================
 
        For any 3rd-party extension types, the array type will be an
        ExtensionArray.
 
        For all remaining dtypes ``.array`` will be a
        :class:`arrays.NumpyExtensionArray` wrapping the actual ndarray
        stored within. If you absolutely need a NumPy array (possibly with
        copying / coercing data), then use :meth:`Series.to_numpy` instead.
 
        Examples
        --------
        For regular NumPy types like int, and float, a PandasArray
        is returned.
 
        >>> pd.Series([1, 2, 3]).array
        <PandasArray>
        [1, 2, 3]
        Length: 3, dtype: int64
 
        For extension types, like Categorical, the actual ExtensionArray
        is returned
 
        >>> ser = pd.Series(pd.Categorical(['a', 'b', 'a']))
        >>> ser.array
        ['a', 'b', 'a']
        Categories (2, object): ['a', 'b']
        NrrArCrCrDÚarrayns?zIndexOpsMixin.arrayNFznpt.DTypeLike | NoneÚboolrIz
np.ndarray)rÚcopyÚna_valuerHcKst|jƒr$|jj|f||dœ|—ŽS|rHt| ¡ƒd}td|›dƒ‚|tjk    rŽ|j    }t
||ƒsrt j ||d}n|  ¡}||t  | ¡¡<n|j    }t j ||d}|r°|tjksº|sütƒrüt  |j    dd…|dd…¡rütƒrô|sô| ¡}d|j_n|  ¡}|S)    a«
        A NumPy ndarray representing the values in this Series or Index.
 
        Parameters
        ----------
        dtype : str or numpy.dtype, optional
            The dtype to pass to :meth:`numpy.asarray`.
        copy : bool, default False
            Whether to ensure that the returned value is not a view on
            another array. Note that ``copy=False`` does not *ensure* that
            ``to_numpy()`` is no-copy. Rather, ``copy=True`` ensure that
            a copy is made, even if not strictly necessary.
        na_value : Any, optional
            The value to use for missing values. The default value depends
            on `dtype` and the type of the array.
        **kwargs
            Additional keywords passed through to the ``to_numpy`` method
            of the underlying array (for extension arrays).
 
        Returns
        -------
        numpy.ndarray
 
        See Also
        --------
        Series.array : Get the actual data stored within.
        Index.array : Get the actual data stored within.
        DataFrame.to_numpy : Similar method for DataFrame.
 
        Notes
        -----
        The returned array will be the same up to equality (values equal
        in `self` will be equal in the returned array; likewise for values
        that are not equal). When `self` contains an ExtensionArray, the
        dtype may be different. For example, for a category-dtype Series,
        ``to_numpy()`` will return a NumPy array and the categorical dtype
        will be lost.
 
        For NumPy dtypes, this will be a reference to the actual data stored
        in this Series or Index (assuming ``copy=False``). Modifying the result
        in place will modify the data stored in the Series or Index (not that
        we recommend doing that).
 
        For extension types, ``to_numpy()`` *may* require copying data and
        coercing the result to a NumPy type (possibly object), which may be
        expensive. When you need a no-copy reference to the underlying data,
        :attr:`Series.array` should be used instead.
 
        This table lays out the different dtypes and default return types of
        ``to_numpy()`` for various dtypes within pandas.
 
        ================== ================================
        dtype              array type
        ================== ================================
        category[T]        ndarray[T] (same dtype as input)
        period             ndarray[object] (Periods)
        interval           ndarray[object] (Intervals)
        IntegerNA          ndarray[object]
        datetime64[ns]     datetime64[ns]
        datetime64[ns, tz] ndarray[object] (Timestamps)
        ================== ================================
 
        Examples
        --------
        >>> ser = pd.Series(pd.Categorical(['a', 'b', 'a']))
        >>> ser.to_numpy()
        array(['a', 'b', 'a'], dtype=object)
 
        Specify the `dtype` to control how datetime-aware data is represented.
        Use ``dtype=object`` to return an ndarray of pandas :class:`Timestamp`
        objects, each with the correct ``tz``.
 
        >>> ser = pd.Series(pd.date_range('2000', periods=2, tz="CET"))
        >>> ser.to_numpy(dtype=object)
        array([Timestamp('2000-01-01 00:00:00+0100', tz='CET'),
               Timestamp('2000-01-02 00:00:00+0100', tz='CET')],
              dtype=object)
 
        Or ``dtype='datetime64[ns]'`` to return an ndarray of native
        datetime64 values. The values are converted to UTC and the timezone
        info is dropped.
 
        >>> ser.to_numpy(dtype="datetime64[ns]")
        ... # doctest: +ELLIPSIS
        array(['1999-12-31T23:00:00.000000000', '2000-01-01T23:00:00...'],
              dtype='datetime64[ns]')
        )rržrz/to_numpy() got an unexpected keyword argument 'rg©rNr~F)rrr›Úto_numpyrrÚkeysÚ    TypeErrorrÚ
no_defaultrrrtZasarrayrZ
asanyarrayr%r Z shares_memoryÚviewÚflagsZ    writeable)rBrrržr‹r‡ÚvaluesÚresultrCrCrDr ¯s4_
 
ÿ
 
ÿÿ
 
zIndexOpsMixin.to_numpycCs|j Srp)ršrArCrCrDÚempty3szIndexOpsMixin.emptyTzAxisInt | None)rzÚskipnacOs&t |¡t ||¡tj|j|dS)a
        Return the maximum value of the Index.
 
        Parameters
        ----------
        axis : int, optional
            For compatibility with NumPy. Only 0 or None are allowed.
        skipna : bool, default True
            Exclude NA/null values when showing the result.
        *args, **kwargs
            Additional arguments and keywords for compatibility with NumPy.
 
        Returns
        -------
        scalar
            Maximum value.
 
        See Also
        --------
        Index.min : Return the minimum value in an Index.
        Series.max : Return the maximum value in a Series.
        DataFrame.max : Return the maximum values in a DataFrame.
 
        Examples
        --------
        >>> idx = pd.Index([3, 2, 1])
        >>> idx.max()
        3
 
        >>> idx = pd.Index(['c', 'b', 'a'])
        >>> idx.max()
        'c'
 
        For a MultiIndex, the maximum is determined lexicographically.
 
        >>> idx = pd.MultiIndex.from_product([('a', 'b'), (2, 1)])
        >>> idx.max()
        ('b', 2)
        ©r©)r‘Úvalidate_minmax_axisZ validate_maxr(Znanmaxr©rBrzr©rŠr‹rCrCrDÚmax8s(
 zIndexOpsMixin.maxr­ÚminÚlargest)ÚopZopposerj)rzr©rHcOsX|j}t |¡t |||¡}t|tƒrF|s<| ¡ ¡r<dS| ¡Snt    j
||dSdS)ab
        Return int position of the {value} value in the Series.
 
        If the {op}imum is achieved in multiple locations,
        the first row position is returned.
 
        Parameters
        ----------
        axis : {{None}}
            Unused. Parameter needed for compatibility with DataFrame.
        skipna : bool, default True
            Exclude NA/null values when showing the result.
        *args, **kwargs
            Additional arguments and keywords for compatibility with NumPy.
 
        Returns
        -------
        int
            Row position of the {op}imum value.
 
        See Also
        --------
        Series.arg{op} : Return position of the {op}imum value.
        Series.arg{oppose} : Return position of the {oppose}imum value.
        numpy.ndarray.arg{op} : Equivalent method for numpy arrays.
        Series.idxmax : Return index label of the maximum values.
        Series.idxmin : Return index label of the minimum values.
 
        Examples
        --------
        Consider dataset containing cereal calories
 
        >>> s = pd.Series({{'Corn Flakes': 100.0, 'Almond Delight': 110.0,
        ...                'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}})
        >>> s
        Corn Flakes              100.0
        Almond Delight           110.0
        Cinnamon Toast Crunch    120.0
        Cocoa Puff               110.0
        dtype: float64
 
        >>> s.argmax()
        2
        >>> s.argmin()
        0
 
        The maximum cereal calories is the third element and
        the minimum cereal calories is the first element,
        since series is zero-indexed.
        r}rªN) rr‘r«Zvalidate_argmax_with_skipnarqr,r%ÚanyÚargmaxr(Z    nanargmax©rBrzr©rŠr‹ZdelegaterCrCrDr²ds6
 
 
ÿzIndexOpsMixin.argmaxcOs&t |¡t ||¡tj|j|dS)a
        Return the minimum value of the Index.
 
        Parameters
        ----------
        axis : {None}
            Dummy argument for consistency with Series.
        skipna : bool, default True
            Exclude NA/null values when showing the result.
        *args, **kwargs
            Additional arguments and keywords for compatibility with NumPy.
 
        Returns
        -------
        scalar
            Minimum value.
 
        See Also
        --------
        Index.max : Return the maximum value of the object.
        Series.min : Return the minimum value in a Series.
        DataFrame.min : Return the minimum values in a DataFrame.
 
        Examples
        --------
        >>> idx = pd.Index([3, 2, 1])
        >>> idx.min()
        1
 
        >>> idx = pd.Index(['c', 'b', 'a'])
        >>> idx.min()
        'a'
 
        For a MultiIndex, the minimum is determined lexicographically.
 
        >>> idx = pd.MultiIndex.from_product([('a', 'b'), (2, 1)])
        >>> idx.min()
        ('a', 1)
        rª)r‘r«Z validate_minr(Znanminrr¬rCrCrDr®ªs(
 zIndexOpsMixin.minÚsmallestcOsX|j}t |¡t |||¡}t|tƒrF|s<| ¡ ¡r<dS| ¡Snt    j
||dSdS)Nr}rª) rr‘r«Zvalidate_argmin_with_skipnarqr,r%r±Úargminr(Z    nanargminr³rCrCrDrµÖs
 
 
ÿzIndexOpsMixin.argmincCs
|j ¡S)a–
        Return a list of the values.
 
        These are each a scalar type, which is a Python scalar
        (for str, int, float) or a pandas scalar
        (for Timestamp/Timedelta/Interval/Period)
 
        Returns
        -------
        list
 
        See Also
        --------
        numpy.ndarray.tolist : Return the array as an a.ndim-levels deep
            nested list of Python scalars.
        )rrrArCrCrDrêszIndexOpsMixin.tolistrcCs2t|jtjƒst|jƒSt|jjt|jjƒƒSdS)a
        Return an iterator of the values.
 
        These are each a scalar type, which is a Python scalar
        (for str, int, float) or a pandas scalar
        (for Timestamp/Timedelta/Interval/Period)
 
        Returns
        -------
        iterator
        N)    rqrrtrur–Úmapr˜ÚrangeršrArCrCrDÚ__iter__ÿs 
zIndexOpsMixin.__iter__cCstt|ƒ ¡ƒS)z‘
        Return True if there are any NaNs.
 
        Enables various performance speedups.
 
        Returns
        -------
        bool
        )rœr%r±rArCrCrDÚhasnanss zIndexOpsMixin.hasnansznpt.NDArray[np.bool_]cCs
t|jƒSrp)r%rrArCrCrDr%!szIndexOpsMixin.isnar)rzr©Ú numeric_onlyÚ filter_typerFr)Únamerzr©c    Ks>t||dƒ}|dkr,tt|ƒj›d|›ƒ‚|fd|i|—ŽS)zA
        Perform the reduction type operation if we can.
        Nz cannot perform the operation r©)rVr¢r@r\)    rBr°r¼rzr©rºr»Úkwdsr‰rCrCrDÚ_reduce$s  ÿzIndexOpsMixin._reducec
sjt|ƒr^t|tƒr.t|dƒr.|‰‡fdd„}n0ddlm}t|ƒdkrV||tjd}n||ƒ}t|t    ƒrÞ|dkr„d|›d    }t
|ƒ‚|d
krš||j   ¡}t |jƒrºtd |jƒ}| |¡S|j}|j  |¡}t |j|¡}|St|jƒrt|jd ƒr|j}|d k    r t‚dd„}    nF|j t¡}|d
kr6dd„}    n&|d krHtj}    nd|›d    }t
|ƒ‚|    ||ƒ}|S)a—
        An internal function that maps values using the input
        correspondence (which can be a dict, Series, or function).
 
        Parameters
        ----------
        mapper : function, dict, or Series
            The input correspondence object
        na_action : {None, 'ignore'}
            If 'ignore', propagate NA values, without passing them to the
            mapping function
 
        Returns
        -------
        Union[Index, MultiIndex], inferred
            The output of the mapping function applied to the index.
            If the function returns a tuple with more than one element
            a MultiIndex will be returned.
        Ú __missing__cs"ˆt|tƒrt |¡rtjn|Srp)rqÚfloatrtÚisnanÚnan)Úx©Zdict_with_defaultrCrDÚ<lambda>Vsÿz+IndexOpsMixin._map_values.<locals>.<lambda>r)r5rŸ)NÚignorez+na_action must either be 'ignore' or None, z  was passedrÆr3r¶NcSs
| |¡Srp)r¶©r¦ÚfrCrCrDrŋócSst ||t|ƒ tj¡¡Srp)rZmap_infer_maskr%r¤rtZuint8rÇrCrCrDrŏsÿ)rrqÚdictrNÚpandasr5r{rtÚfloat64r$r—ÚindexZnotnarrr
rr¶Z get_indexerr'Ztake_ndrÚNotImplementedErrorÚastyperIrZ    map_infer)
rBZmapperZ    na_actionr5ÚmsgÚcatr¦ZindexerZ
new_valuesZmap_frCrÄrDÚ _map_values9sJ  
 
ÿ
 
 
 
 
 
 
 
ÿ
zIndexOpsMixin._map_valuesr5)Ú    normalizeÚsortÚ    ascendingÚdropnarHcCstj||||||dS)a    
        Return a Series containing counts of unique values.
 
        The resulting object will be in descending order so that the
        first element is the most frequently-occurring element.
        Excludes NA values by default.
 
        Parameters
        ----------
        normalize : bool, default False
            If True then the object returned will contain the relative
            frequencies of the unique values.
        sort : bool, default True
            Sort by frequencies.
        ascending : bool, default False
            Sort in ascending order.
        bins : int, optional
            Rather than count values, group them into half-open bins,
            a convenience for ``pd.cut``, only works with numeric data.
        dropna : bool, default True
            Don't include counts of NaN.
 
        Returns
        -------
        Series
 
        See Also
        --------
        Series.count: Number of non-NA elements in a Series.
        DataFrame.count: Number of non-NA elements in a DataFrame.
        DataFrame.value_counts: Equivalent method on DataFrames.
 
        Examples
        --------
        >>> index = pd.Index([3, 1, 2, 3, 4, np.nan])
        >>> index.value_counts()
        3.0    2
        1.0    1
        2.0    1
        4.0    1
        Name: count, dtype: int64
 
        With `normalize` set to `True`, returns the relative frequency by
        dividing all values by the sum of values.
 
        >>> s = pd.Series([3, 1, 2, 3, 4, np.nan])
        >>> s.value_counts(normalize=True)
        3.0    0.4
        1.0    0.2
        2.0    0.2
        4.0    0.2
        Name: proportion, dtype: float64
 
        **bins**
 
        Bins can be useful for going from a continuous variable to a
        categorical variable; instead of counting unique
        apparitions of values, divide the index in the specified
        number of half-open bins.
 
        >>> s.value_counts(bins=3)
        (0.996, 2.0]    2
        (2.0, 3.0]      2
        (3.0, 4.0]      1
        Name: count, dtype: int64
 
        **dropna**
 
        With `dropna` set to `False` we can also see NaN index values.
 
        >>> s.value_counts(dropna=False)
        3.0    2
        1.0    1
        2.0    1
        4.0    1
        NaN    1
        Name: count, dtype: int64
        )rÔrÕrÓÚbinsrÖ)r'Ú value_counts)rBrÓrÔrÕr×rÖrCrCrDrØ sWúzIndexOpsMixin.value_countscCs*|j}t|tjƒs| ¡}n
t |¡}|Srp)rrqrtrur:r'Zunique1d)rBr¦r§rCrCrDr:s
 
 
zIndexOpsMixin.unique)rÖrHcCs| ¡}|rt|ƒ}t|ƒS)aŒ
        Return number of unique elements in the object.
 
        Excludes NA values by default.
 
        Parameters
        ----------
        dropna : bool, default True
            Don't include NaN in the count.
 
        Returns
        -------
        int
 
        See Also
        --------
        DataFrame.nunique: Method nunique for DataFrame.
        Series.count: Count non-NA/null observations in the Series.
 
        Examples
        --------
        >>> s = pd.Series([1, 3, 5, 7, 7])
        >>> s
        0    1
        1    3
        2    5
        3    7
        4    7
        dtype: int64
 
        >>> s.nunique()
        4
        )r:r&r{)rBrÖZuniqsrCrCrDÚnunique    s#zIndexOpsMixin.nuniquecCs|jddt|ƒkS)zr
        Return boolean if values in the object are unique.
 
        Returns
        -------
        bool
        F)rÖ)rÙr{rArCrCrDÚ    is_unique1s    zIndexOpsMixin.is_uniquecCsddlm}||ƒjS)z„
        Return boolean if values in the object are monotonically increasing.
 
        Returns
        -------
        bool
        r©r4)rËr4Úis_monotonic_increasing©rBr4rCrCrDrÜ<s     z%IndexOpsMixin.is_monotonic_increasingcCsddlm}||ƒjS)z„
        Return boolean if values in the object are monotonically decreasing.
 
        Returns
        -------
        bool
        rrÛ)rËr4Úis_monotonic_decreasingrÝrCrCrDrÞIs     z%IndexOpsMixin.is_monotonic_decreasing)rUrHcCsRt|jdƒr|jj|dS|jj}|rNt|ƒrNtsNttj|j    ƒ}|t
  |¡7}|S)aN
        Memory usage of the values.
 
        Parameters
        ----------
        deep : bool, default False
            Introspect the data deeply, interrogate
            `object` dtypes for system-level memory consumption.
 
        Returns
        -------
        bytes used
 
        See Also
        --------
        numpy.ndarray.nbytes : Total bytes consumed by the elements of the
            array.
 
        Notes
        -----
        Memory usage does not include memory consumed by elements that
        are not components of the array if deep=False or if used on PyPy
        rSrT) rNr›rSr™r rr
rtrurrZmemory_usage_of_objects)rBrUÚvr¦rCrCrDÚ _memory_usageVs ÿzIndexOpsMixin._memory_usager8z”            sort : bool, default False
                Sort `uniques` and shuffle `codes` to maintain the
                relationship.
            )r¦ÚorderZ    size_hintrÔz"tuple[npt.NDArray[np.intp], Index])rÔÚuse_na_sentinelrHcCs`tj|j||d\}}|jtjkr.| tj¡}t|t    ƒrD| 
|¡}nddl m }||ƒ}||fS)N)rÔrârrÛ) r'Ú    factorizerrrtÚfloat16rÏÚfloat32rqr#rErËr4)rBrÔrâÚcodesZuniquesr4rCrCrDrãzsÿ
 
  zIndexOpsMixin.factorizea
        Find indices where elements should be inserted to maintain order.
 
        Find the indices into a sorted {klass} `self` such that, if the
        corresponding elements in `value` were inserted before the indices,
        the order of `self` would be preserved.
 
        .. note::
 
            The {klass} *must* be monotonically sorted, otherwise
            wrong locations will likely be returned. Pandas does *not*
            check this for you.
 
        Parameters
        ----------
        value : array-like or scalar
            Values to insert into `self`.
        side : {{'left', 'right'}}, optional
            If 'left', the index of the first suitable location found is given.
            If 'right', return the last such index.  If there is no suitable
            index, return either 0 or N (where N is the length of `self`).
        sorter : 1-D array-like, optional
            Optional array of integer indices that sort `self` into ascending
            order. They are typically the result of ``np.argsort``.
 
        Returns
        -------
        int or array of int
            A scalar or array of insertion points with the
            same shape as `value`.
 
        See Also
        --------
        sort_values : Sort by the values along either axis.
        numpy.searchsorted : Similar method from NumPy.
 
        Notes
        -----
        Binary search is used to find the required insertion points.
 
        Examples
        --------
        >>> ser = pd.Series([1, 2, 3])
        >>> ser
        0    1
        1    2
        2    3
        dtype: int64
 
        >>> ser.searchsorted(4)
        3
 
        >>> ser.searchsorted([0, 4])
        array([0, 3])
 
        >>> ser.searchsorted([1, 3], side='left')
        array([0, 2])
 
        >>> ser.searchsorted([1, 3], side='right')
        array([1, 3])
 
        >>> ser = pd.Series(pd.to_datetime(['3/11/2000', '3/12/2000', '3/13/2000']))
        >>> ser
        0   2000-03-11
        1   2000-03-12
        2   2000-03-13
        dtype: datetime64[ns]
 
        >>> ser.searchsorted('3/14/2000')
        3
 
        >>> ser = pd.Categorical(
        ...     ['apple', 'bread', 'bread', 'cheese', 'milk'], ordered=True
        ... )
        >>> ser
        ['apple', 'bread', 'bread', 'cheese', 'milk']
        Categories (4, object): ['apple' < 'bread' < 'cheese' < 'milk']
 
        >>> ser.searchsorted('bread')
        1
 
        >>> ser.searchsorted(['bread'], side='right')
        array([3])
 
        If the values are not monotonically sorted, wrong locations
        may be returned:
 
        >>> ser = pd.Series([2, 1, 3])
        >>> ser
        0    2
        1    1
        2    3
        dtype: int64
 
        >>> ser.searchsorted(1)  # doctest: +SKIP
        0  # wrong result, correct would be 1
        Ú searchsorted.r2zLiteral[('left', 'right')]r0znp.intp)rjÚsideÚsorterrHcCsdSrprC©rBrjrèrérCrCrDrçs zIndexOpsMixin.searchsortedznpt.ArrayLike | ExtensionArrayznpt.NDArray[np.intp]cCsdSrprCrêrCrCrDrçsr4)r9Úleftz$NumpyValueArrayLike | ExtensionArrayznpt.NDArray[np.intp] | np.intpcCsXt|tƒr$dt|ƒj›d}t|ƒ‚|j}t|tjƒsF|j|||dSt    j||||dS)Nz(Value must be 1-D array-like or scalar, z is not supported)rèré)
rqr"r@r\r—rrtrurçr')rBrjrèrérÐr¦rCrCrDrçs
ÿ üÚfirst©Úkeepr/cCs|j|d}||S©Nrí)Ú _duplicated)rBrîr;rCrCrDÚdrop_duplicates2s zIndexOpsMixin.drop_duplicates)rîrHcCstj|j|dSrï)r'r;r)rBrîrCrCrDrð7szIndexOpsMixin._duplicatedc    Csjt ||¡}|j}t|ddd}t ||j¡}t|ƒ}tjddt     |||¡}W5QRX|j
||dS)NT)Z extract_numpyZ extract_rangerÆ)Úall)r¼) r)Zget_op_result_namerr.Zmaybe_prepare_scalar_for_opr“r-rtZerrstateZ arithmetic_opÚ_construct_result)rBÚotherr°Zres_nameZlvaluesZrvaluesr§rCrCrDÚ _arith_method;s zIndexOpsMixin._arith_methodcCs t|ƒ‚dS)z~
        Construct an appropriately-wrapped result from the ArrayLike result
        of an arithmetic-like operation.
        Nr)rBr§r¼rCrCrDróHszIndexOpsMixin._construct_result)NT)NT)NT)NT)N)FTFNT)T)F)FT)..)..)rëN)rì)8r\r]r^r_Z__array_priority__Ú    frozensetrŽr`rarrr r’ÚTr“r”rxr˜r™ršr›rr£r r¨r­rr²r®rµrZto_listr¸rr¹r%r¾rÒrØr:rÙrÚrÜrÞràr'rãÚtextwrapÚdedentr6r rçrñrðrõrórCrCrCrDr7 sÞ
ÿ  þ 
@ü, ÿE,ÿø fú_    '
  #ÿûýþÿgüüü )Sr_Ú
__future__rrøÚtypingrrrrrrr    r
r r ÚnumpyrtZpandas._configr Z pandas._libsrZpandas._typingrrrrrrrZ pandas.compatrZpandas.compat.numpyrr‘Z pandas.errorsrZpandas.util._decoratorsrrZpandas.core.dtypes.castrZpandas.core.dtypes.commonrrrr r!Zpandas.core.dtypes.genericr"r#r$Zpandas.core.dtypes.missingr%r&Z pandas.corer'r(r)Zpandas.core.accessorr*Zpandas.core.arrayliker+Zpandas.core.arraysr,Zpandas.core.constructionr-r.r/r0r1r2rËr3r4r5r6r`Z_indexops_doc_kwargsr<r>rcrkr7rCrCrCrDÚ<module>sD 0   $            ü /"X