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
U
¬ý°dGïã @s–UddlmZddlZddlmZmZddlZddlmZmZm    Z    m
Z
m Z m Z m Z mZddlZddlmZddlmZddlmZmZmZmZddlmZdd    lmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'dd
l(m)Z*dd l+m,Z,dd l-m.Z.dd l/m0Z0m1Z1ddl2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=ddl>m?Z?ddl@mAZAmBZBmCZCmDZDddlEmFZFmGZGmHZHddlImJZJmKZKmLZLmMZMddlNmOZOmPZPddlQmRZRddlSmTZTddlUmVmWZXddlYmZZ[m\Z\m]Z]ddl^m_Z_ddl`maZambZberddlcmdZdmeZee dddZfe e&ejgfZhe eeifZjiZkdeld<ddd d!œZmd"ekd#<e.ekd#dd$d%d d d e nd&¡d'œƒGd(d„deeOƒƒZod)d*œd+d,„ZpdS)-é)Ú annotationsN)ÚleÚlt)Ú TYPE_CHECKINGÚIteratorÚLiteralÚSequenceÚTypeVarÚUnionÚcastÚoverload)Ú
get_option)Úlib)Ú VALID_CLOSEDÚIntervalÚ IntervalMixinÚintervals_to_interval_bounds)ÚNA) Ú    ArrayLikeÚAxisIntÚDtypeÚIntervalClosedTypeÚNpDtypeÚPositionalIndexerÚ ScalarIndexerÚSequenceIndexerÚSortKindÚ TimeArrayLikeÚnpt)Úfunction)ÚIntCastingNaNError)ÚAppender)ÚLossySetitemErrorÚmaybe_upcast_numeric_to_64bit) Úis_categorical_dtypeÚis_dtype_equalÚis_float_dtypeÚis_integer_dtypeÚis_interval_dtypeÚ is_list_likeÚis_object_dtypeÚ    is_scalarÚis_string_dtypeÚneeds_i8_conversionÚ pandas_dtype)Ú IntervalDtype)Ú ABCDataFrameÚABCDatetimeIndexÚABCIntervalIndexÚABCPeriodIndex)Úis_valid_na_for_dtypeÚisnaÚnotna)ÚisinÚtakeÚuniqueÚ value_counts)ÚExtensionArrayÚ_extension_array_shared_docs)Ú DatetimeArray)ÚTimedeltaArray)ÚarrayÚensure_wrapped_if_datetimelikeÚ extract_array)Úcheck_array_indexer)Úinvalid_comparisonÚunpack_zerodim_and_defer)ÚIndexÚSeriesÚIntervalArrayTÚ IntervalArray)Úboundzdict[str, str]Ú_interval_shared_docszarrays.IntervalArrayÚ)ÚklassÚqualnameÚnamea 
%(summary)s
 
.. versionadded:: %(versionadded)s
 
Parameters
----------
data : array-like (1-dimensional)
    Array-like (ndarray, :class:`DateTimeArray`, :class:`TimeDeltaArray`) containing
    Interval objects from which to build the %(klass)s.
closed : {'left', 'right', 'both', 'neither'}, default 'right'
    Whether the intervals are closed on the left-side, right-side, both or
    neither.
dtype : dtype or None, default None
    If None, dtype will be inferred.
copy : bool, default False
    Copy the input data.
%(name)sverify_integrity : bool, default True
    Verify that the %(klass)s is valid.
 
Attributes
----------
left
right
closed
mid
length
is_empty
is_non_overlapping_monotonic
%(extra_attributes)s
Methods
-------
from_arrays
from_tuples
from_breaks
contains
overlaps
set_closed
to_tuples
%(extra_methods)s
See Also
--------
Index : The base pandas Index type.
Interval : A bounded slice-like interval; the elements of an %(klass)s.
interval_range : Function to create a fixed frequency IntervalIndex.
cut : Bin values into discrete Intervals.
qcut : Bin values into equal-sized Intervals based on rank or sample quantiles.
 
Notes
-----
See the `user guide
<https://pandas.pydata.org/pandas-docs/stable/user_guide/advanced.html#intervalindex>`__
for more.
 
%(examples)sÚclassz@Pandas array for interval data that are closed on the same side.z0.24.0aà    Examples
    --------
    A new ``IntervalArray`` can be constructed directly from an array-like of
    ``Interval`` objects:
 
    >>> pd.arrays.IntervalArray([pd.Interval(0, 1), pd.Interval(1, 5)])
    <IntervalArray>
    [(0, 1], (1, 5]]
    Length: 2, dtype: interval[int64, right]
 
    It may also be constructed using one of the constructor
    methods: :meth:`IntervalArray.from_arrays`,
    :meth:`IntervalArray.from_breaks`, and :meth:`IntervalArray.from_tuples`.
    )rLÚsummaryZ versionaddedrNZextra_attributesZ extra_methodsÚexamplesc    s
eZdZUdZejZZeddœdd„ƒZ    de
d<de
d<d    e
d
<dçd ddddœdd„Z e d ddd    ddœdd„ƒZ e dèdddddœdd„ƒZe d d dœd ddddœdd„ƒZe d d ddd!œd"d#„ƒZe d$¡ed%<e eed%dd&e d'¡d(œƒdéd ddddd*œd+d,„ƒƒZe d-¡ed.<e eed.dd&e d/¡d(œƒdêd ddddd*œd0d1„ƒƒZe d2¡ed3<e eed3dd&e d4¡d(œƒdëd ddddd*œd5d6„ƒƒZe d    d7d8œd9d:„ƒZddd;œd<d=„Zed    dœd>d?„ƒZed@dœdAdB„ƒZed@dœdCdD„ƒZdEdœdFdG„Zd@dœdHdI„ZedJdKdLœdMdN„ƒZ eddOddPœdQdN„ƒZ ddRdSdPœdTdN„Z d7dœdUdV„Z!dWdX„Z"e#dYƒdZd[„ƒZ$e#d\ƒd]d^„ƒZ%e#d_ƒd`da„ƒZ&e#dbƒdcdd„ƒZ'e#deƒdfdg„ƒZ(e#dhƒdidj„ƒZ)ddkdldmœddndod dpœ‡fdqdr„Z*d ddsœdtddKduœdvdw„Z+d ddsœdtddKduœdxdy„Z,dìddd;œdzd{„Z-dídd|œ‡fd}d~„ Z.ddœdd€„Z/e d ddd‚œdƒd„„ƒZ0ddd;œd…d†„Z1d dœd‡dˆ„Z2dîd@dŠdd‹œdŒd„Z3d d d dŽœddddœdd‘„Z4d’d“„Z5d”d•„Z6d–d—„Z7dïdd˜d™œdšd›„Z8dodœdœd„Z9dodœdždŸ„Z:dodœd d¡„Z;ed¢d£„ƒZ<ed¤d¥„ƒZ=ed¦dœd§d¨„ƒZ>ed¦dœd©dª„ƒZ?e d«¡ed¬<eed¬de d­¡d®œƒd¯d°„ƒZ@ed±dœd²d³„ƒZAe d´¡edµ<eedµde d¶¡d®œƒdd±dd·œd¸d¹„ƒZBdºed»<eeed»eCƒddœd¼d½„ƒƒZDdðd¾d d8œd¿dÀ„ZEdñdÁd„ZFdÃedÄ<eedÄdÅd&dƜƒdòdd dǜdÈdɄƒZGdÊd7d˜dÌd̈́ZHdd@dÎddϜdÐdфZIddd;œdÒdӄZJeeKdÔeCƒdóddÕdtdd֜d×d؄ƒZLe dÙ¡edÚ<eedÚde dÛ¡d®œƒdÜd݄ƒZMdÊdœdÞd߄ZNeddœdàdᄃZOd ddâœdãdä„ZPddœdådæ„ZQ‡ZRS)ôrHTz
Literal[1]©ÚreturncCsdS)Né©©ÚselfrUrUúRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/arrays/interval.pyÚndimÚszIntervalArray.ndimÚ IntervalSideTÚ_leftÚ_rightr/Ú_dtypeNFztype[IntervalArrayT]z Dtype | NoneÚbool)ÚclsÚdtypeÚcopyÚverify_integrityc
Csàt|dd}t||ƒr<|j}|j}|p*|j}t|j|d}n€t|ƒr^|j›d|›d}t    |ƒ‚t
|ƒ}t ||dkd\}}}    |jt kršt  |¡}t  |¡}|p |    }|j|||||d\}}}|rÐ|j|||d|j|||dS)    NT©Z extract_numpy©Úclosedz5(...) must be called with a collection of some kind, z  was passed)Zvalidate_closed©rerar`©r`)rAÚ
isinstancer[r\rer/r`r+Ú__name__Ú    TypeErrorÚ _maybe_convert_platform_intervalrÚobjectrZmaybe_convert_objectsÚ_ensure_simple_new_inputsÚ    _validateÚ _simple_new)
r_Údatarer`rarbÚleftÚrightÚmsgZ infer_closedrUrUrXÚ__new__æsB 
 
ÿÿ 
 
 
û ýzIntervalArray.__new__rG)r_rqrrr`rScCs t |¡}||_||_||_|S©N)rrtr[r\r])r_rqrrr`ÚresultrUrUrXros
 
zIntervalArray._simple_newzIntervalClosedType | Nonez2tuple[IntervalSideT, IntervalSideT, IntervalDtype])rerar`rSc
Cs@ddlm}|||d}t|ƒ}|||d}t|ƒ}|dkrLt|tƒrL|j}|pRd}|dk    rÖt|ƒ}t|ƒrštt|ƒ}|j    dk    r¬| 
|j    ¡}| 
|j    ¡}nd|›}t |ƒ‚|jdkrÄt|j    |ƒ}n||jkrÖt dƒ‚t |ƒrôt|ƒrô| 
|j¡}n t |ƒrt|ƒr| 
|j¡}t|ƒt|ƒkrLdt|ƒj›d    t|ƒj›d
}t |ƒ‚t|jƒsdt|jƒrpd }t |ƒ‚t|tƒrˆd }t |ƒ‚t|tƒrÈt|jƒt|jƒkrÈd |j›d|j›d}t |ƒ‚t|ƒ}t|dd}t|ƒ}t|dd}t|d|ƒj}t|d|ƒj}    |dk    r(||    kr(| ¡}t|j|d}|||fS)z;Ensure correctness of input parameters for cls._simple_new.r)Ú ensure_index©raNrrz$dtype must be an IntervalDtype, got z*closed keyword does not match dtype.closedzmust not have differing left [z ] and right [z] typeszIcategory, object, and string subtypes are not supported for IntervalArrayz:Period dtypes are not supported, use a PeriodIndex insteadz2left and right must have the same time zone, got 'z' and 'ú'TrcZ_ndarrayrd)Zpandas.core.indexes.baserwr#rhr/rer.r(r ÚsubtypeÚastyperjÚ
ValueErrorr&r'r`Útyperir$r,r3r1ÚstrÚtzr@rAÚgetattrÚbasera)
r_rqrrrerar`rwrsZlbaseZrbaserUrUrXrm'sd
 
 
 
 
 
 ÿÿ "ÿ  z'IntervalArray._ensure_simple_new_inputs©r`ra)r_r`rarScCs||||dS)Nr‚rU)r_Zscalarsr`rarUrUrXÚ_from_sequence}szIntervalArray._from_sequencez
np.ndarray)r_ÚvaluesÚoriginalrScCs(t|ƒdkr| |jj¡}|||jdS)Nrrd)Úlenr{r`rzre)r_r„r…rUrUrXÚ_from_factorized‡s zIntervalArray._from_factorizedac
        Construct an %(klass)s from an array of splits.
 
        Parameters
        ----------
        breaks : array-like (1-dimensional)
            Left and right bounds for each interval.
        closed : {'left', 'right', 'both', 'neither'}, default 'right'
            Whether the intervals are closed on the left-side, right-side, both
            or neither.        %(name)s
        copy : bool, default False
            Copy the data.
        dtype : dtype or None, default None
            If None, dtype will be inferred.
 
        Returns
        -------
        %(klass)s
 
        See Also
        --------
        interval_range : Function to create a fixed frequency IntervalIndex.
        %(klass)s.from_arrays : Construct from a left and right array.
        %(klass)s.from_tuples : Construct from a sequence of tuples.
 
        %(examples)s        Ú from_breaksrKzÒ        Examples
        --------
        >>> pd.arrays.IntervalArray.from_breaks([0, 1, 2, 3])
        <IntervalArray>
        [(0, 1], (1, 2], (2, 3]]
        Length: 3, dtype: interval[int64, right]
        )rLrNrQrr)r_rerar`rScCs,t|ƒ}|j|dd…|dd…|||dS)NéÿÿÿÿrT©rar`)rkÚ from_arrays)r_Zbreaksrerar`rUrUrXrˆ±szIntervalArray.from_breaksaC
        Construct from two arrays defining the left and right bounds.
 
        Parameters
        ----------
        left : array-like (1-dimensional)
            Left bounds for each interval.
        right : array-like (1-dimensional)
            Right bounds for each interval.
        closed : {'left', 'right', 'both', 'neither'}, default 'right'
            Whether the intervals are closed on the left-side, right-side, both
            or neither.        %(name)s
        copy : bool, default False
            Copy the data.
        dtype : dtype, optional
            If None, dtype will be inferred.
 
        Returns
        -------
        %(klass)s
 
        Raises
        ------
        ValueError
            When a value is missing in only one of `left` or `right`.
            When a value in `left` is greater than the corresponding value
            in `right`.
 
        See Also
        --------
        interval_range : Function to create a fixed frequency IntervalIndex.
        %(klass)s.from_breaks : Construct an %(klass)s from an array of
            splits.
        %(klass)s.from_tuples : Construct an %(klass)s from an
            array-like of tuples.
 
        Notes
        -----
        Each element of `left` must be less than or equal to the `right`
        element at the same position. If an element is missing, it must be
        missing in both `left` and `right`. A TypeError is raised when
        using an unsupported type for `left` or `right`. At the moment,
        'category', 'object', and 'string' subtypes are not supported.
 
        %(examples)s        r‹z¸        >>> pd.arrays.IntervalArray.from_arrays([0, 1, 2], [1, 2, 3])
        <IntervalArray>
        [(0, 1], (1, 2], (2, 3]]
        Length: 3, dtype: interval[int64, right]
        cCsJt|ƒ}t|ƒ}|j|||||d\}}}|j|||d|j|||dS)Nrfrg)rkrmrnro)r_rqrrrerar`rUrUrXr‹sû zIntervalArray.from_arraysaÚ
        Construct an %(klass)s from an array-like of tuples.
 
        Parameters
        ----------
        data : array-like (1-dimensional)
            Array of tuples.
        closed : {'left', 'right', 'both', 'neither'}, default 'right'
            Whether the intervals are closed on the left-side, right-side, both
            or neither.        %(name)s
        copy : bool, default False
            By-default copy the data, this is compat only and ignored.
        dtype : dtype or None, default None
            If None, dtype will be inferred.
 
        Returns
        -------
        %(klass)s
 
        See Also
        --------
        interval_range : Function to create a fixed frequency IntervalIndex.
        %(klass)s.from_arrays : Construct an %(klass)s from a left and
                                    right array.
        %(klass)s.from_breaks : Construct an %(klass)s from an array of
                                    splits.
 
        %(examples)s        Ú from_tupleszΠ       Examples
        --------
        >>> pd.arrays.IntervalArray.from_tuples([(0, 1), (1, 2)])
        <IntervalArray>
        [(0, 1], (1, 2]]
        Length: 2, dtype: interval[int64, right]
        c Csòt|ƒrgg}}n|}}|D]¼}t|tƒsBt|ƒrBtj}}    n†|j}
z |\}}    Wnrtk
rŽ} z|
›d|›} t| ƒ| ‚W5d} ~ XYn:tk
rÆ} z|
›d|›} t| ƒ| ‚W5d} ~ XYnX|     |¡|     |    ¡q |j
|||d|dS)Nz..from_tuples requires tuples of length 2, got z'.from_tuples received an invalid item, FrŠ) r†rhÚtupler5ÚnpÚnanrir|rjÚappendr‹) r_rprerar`rqrrÚdÚlhsÚrhsrNÚerrrsrUrUrXrŒGs$   
 zIntervalArray.from_tuplesÚNone)r`rScCs„t|tƒsd|›}t|ƒ‚t|ƒt|ƒkr8d}t|ƒ‚t|ƒ}t|ƒ}||k ¡s`d}t|ƒ‚||||k ¡s€d}t|ƒ‚dS)zì
        Verify that the IntervalArray is valid.
 
        Checks that
 
        * dtype is correct
        * left and right match lengths
        * left and right have the same missing values
        * left is always below right
        zinvalid dtype: z(left and right must have the same lengthzMmissing values must be missing in the same location both left and right sidesz+left side of interval must be <= right sideN)rhr/r|r†r6Úall)r_rqrrr`rsZ    left_maskZ
right_maskrUrUrXrnys
 
 ÿzIntervalArray._validate)rWrScCs6t|j|jd}|j|||d\}}}|j|||dS)a#
        Return a new IntervalArray with the replacement attributes
 
        Parameters
        ----------
        left : Index
            Values to be used for the left-side of the intervals.
        right : Index
            Values to be used for the right-side of the intervals.
        rdrg)r/r`rermro©rWrqrrr`rUrUrXÚ _shallow_copy—s zIntervalArray._shallow_copycCs|jSru)r]rVrUrUrXr`ªszIntervalArray.dtypeÚintcCs|jj|jjSru)rqÚnbytesrrrVrUrUrXrš®szIntervalArray.nbytescCs|jjSru)rqÚsizerVrUrUrXr›²szIntervalArray.sizercCstt |¡ƒSru)ÚiterrŽÚasarrayrVrUrUrXÚ__iter__ºszIntervalArray.__iter__cCs
t|jƒSru)r†r[rVrUrUrXÚ__len__½szIntervalArray.__len__rÚ IntervalOrNA)ÚkeyrScCsdSrurU©rWr¡rUrUrXÚ __getitem__ÀszIntervalArray.__getitem__r)rWr¡rScCsdSrurUr¢rUrUrXr£ÄsrzIntervalArrayT | IntervalOrNAcCszt||ƒ}|j|}|j|}t|tjtfƒsRt|ƒrDt|ƒrD|j    St
|||j ƒSt  |¡dkrht dƒ‚|j|||jdS)NrTz&multi-dimensional indexing not allowedrg)rBr[r\rhrŽÚndarrayr;r+r5Ú _fill_valuerrerYr|ror`)rWr¡rqrrrUrUrXr£Ès
 
 
cCs0| |¡\}}t||ƒ}||j|<||j|<dSru)Ú_validate_setitem_valuerBr[r\)rWr¡ÚvalueÚ
value_leftÚ value_rightrUrUrXÚ __setitem__Ýs
 
zIntervalArray.__setitem__c
    Cs„t|ƒr*t|ƒt|ƒkr tdƒ‚t|ƒ}nTt|tƒs~|tkrrddlm}t    j
|j t d}t    j |j t d}|||ƒSt|||ƒSt|tƒr’tdƒ}nTt|jƒs¤|j}nB|jj}t|ƒræ|j|jjkrÎt|||ƒS|jj|jd|jjd}t|ƒrö|j|jkr
t|||ƒSt|tƒs"t|ƒ|ƒ}|tjkrF|j|jk|j|jk@S|tjkrj|j|jk|j|jkBS|tj krš|j|jk|j|jk|j|jk@BS|tj!kr¶||k||kBS|tj"kræ|j|jk|j|jk|j|jk@BS||k||kBSt#|ƒs t|||ƒSt    j$t|ƒt d}t%|ƒD]X\}}    z||||    ƒ||<Wn6t&k
rz|    tkrt| 't(¡}t||<n‚YnXq&|S)NzLengths must match to comparer)Ú BooleanArrayrgÚintervalT©Ú
allow_fillÚ
fill_value))r)r†r|Úpd_arrayrhrrZpandas.core.arraysr«rŽÚemptyÚshaper^ZonesrCr.r$r`Ú
categoriesr(rer8ÚcodesÚ    _na_valuer}ÚoperatorÚeqr[rqr\rrÚneÚgtÚgerr*ÚzerosÚ    enumeraterjr{rl)
rWÚotherÚopr«ZarrÚmaskZ other_dtypervÚiÚobjrUrUrXÚ _cmp_methodäsp
 
 
 
 
 
 ÿ
 
ÿ  
ÿ
 
 
 
 zIntervalArray._cmp_methodÚ__eq__cCs| |tj¡Sru)rÂr¶r·©rWr½rUrUrXrÃ3szIntervalArray.__eq__Ú__ne__cCs| |tj¡Sru)rÂr¶r¸rÄrUrUrXrÅ7szIntervalArray.__ne__Ú__gt__cCs| |tj¡Sru)rÂr¶r¹rÄrUrUrXrÆ;szIntervalArray.__gt__Ú__ge__cCs| |tj¡Sru)rÂr¶rºrÄrUrUrXrÇ?szIntervalArray.__ge__Ú__lt__cCs| |tj¡Sru)rÂr¶rrÄrUrUrXrÈCszIntervalArray.__lt__Ú__le__cCs| |tj¡Sru)rÂr¶rrÄrUrUrXrÉGszIntervalArray.__le__Ú    quicksortÚlast©Ú    ascendingÚkindÚ na_positionrr~)rÍrÎrÏrSc sNt |d|¡}|r4|dkr4|dkr4t |j|jf¡Stƒjf|||dœ|—ŽS)NrUrÊrËrÌ)ÚnvZvalidate_argsort_with_ascendingrŽZlexsortrrrqÚsuperÚargsort)rWrÍrÎrÏÚkwargs©Ú    __class__rUrXrÒKsÿÿzIntervalArray.argsort)ÚaxisÚskipnazAxisInt | None)rÖr×rScCsZt ||j¡t|ƒs|jS| ¡}| ¡rB|s6|jS||}n|}| ¡d}||S)Nr©rÐZvalidate_minmax_axisrYr†rµr5ÚanyrÒ©rWrÖr×r¿rÁZindexerrUrUrXÚmin_s  zIntervalArray.mincCsZt ||j¡t|ƒs|jS| ¡}| ¡rB|s6|jS||}n|}| ¡d}||S)Nr‰rØrÚrUrUrXÚmaxps  zIntervalArray.maxcCsV|dk    rtdƒ‚|dk    r tdƒ‚| |¡\}}|jj|d}|jj|d}| ||¡S)a¶
        Fill NA/NaN values using the specified method.
 
        Parameters
        ----------
        value : scalar, dict, Series
            If a scalar value is passed it is used to fill all missing values.
            Alternatively, a Series or dict can be used to fill in different
            values for each index. The value should not be a list. The
            value(s) passed should be either Interval objects or NA/NaN.
        method : {'backfill', 'bfill', 'pad', 'ffill', None}, default None
            (Not implemented yet for IntervalArray)
            Method to use for filling holes in reindexed Series
        limit : int, default None
            (Not implemented yet for IntervalArray)
            If method is specified, this is the maximum number of consecutive
            NaN values to forward/backward fill. 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.
 
        Returns
        -------
        filled : IntervalArray with NA/NaN filled
        Nz5Filling by method is not supported for IntervalArray.z)limit is not supported for IntervalArray.)r§)rjÚ_validate_scalarrqÚfillnarrr˜)rWr§ÚmethodÚlimitr¨r©rqrrrUrUrXrށszIntervalArray.fillnarxc
shddlm}|dk    rt|ƒ}t|ƒr||jkr@|r<| ¡S|St|jjƒrrt|jƒrrd|j›d|›d}t    |ƒ‚z0||j
dd  |j¡}||j dd  |j¡}WnXt k
r¸‚YnDt    tfk
rú}z"d|j›d|›d}t    |ƒ|‚W5d}~XYnX| ||¡Sztƒj ||dWSt    tfk
rb}z$d    t|ƒj›d
|›}t    |ƒ|‚W5d}~XYnXdS) a(
        Cast to an ExtensionArray or NumPy array with dtype 'dtype'.
 
        Parameters
        ----------
        dtype : str or dtype
            Typecode or data-type to which the array is cast.
 
        copy : bool, default True
            Whether to copy the data, even if not necessary. If False,
            a copy is made only if the old dtype does not match the
            new dtype.
 
        Returns
        -------
        array : ExtensionArray or ndarray
            ExtensionArray or NumPy ndarray with 'dtype' for its dtype.
        r©rENzCannot convert z to z; subtypes are incompatibleFrxz Cannot cast z
 to dtype )ÚpandasrEr.r(r`rar&rzr-rjr[r{r\r r|r˜rÑr}ri)rWr`rarErsÚnew_leftÚ    new_rightr”rÔrUrXr{©s6 
 
ÿÿÿ zIntervalArray.astypecCs@t|ƒt|ƒkrdSt|j|jko<|j |j¡o<|j |j¡ƒS)NF)r}r^rerqÚequalsrrrÄrUrUrXråæs  ÿ ýzIntervalArray.equalszSequence[IntervalArrayT])r_Ú    to_concatrScCsxdd„|Dƒ}t|ƒdkr"tdƒ‚| ¡}t dd„|Dƒ¡}t dd„|Dƒ¡}|j|||d\}}}|j|||d    S)
        Concatenate multiple IntervalArray
 
        Parameters
        ----------
        to_concat : sequence of IntervalArray
 
        Returns
        -------
        IntervalArray
        cSsh|]
}|j’qSrUrd©Ú.0r¬rUrUrXÚ    <setcomp>ÿsz2IntervalArray._concat_same_type.<locals>.<setcomp>rTz.Intervals must all be closed on the same side.cSsg|]
}|j‘qSrU)rqrçrUrUrXÚ
<listcomp>sz3IntervalArray._concat_same_type.<locals>.<listcomp>cSsg|]
}|j‘qSrU)rrrçrUrUrXrêsrdrg)r†r|ÚpoprŽÚ concatenatermro)r_ræZ
closed_setrerqrrr`rUrUrXÚ_concat_same_typeðs zIntervalArray._concat_same_typecCs*|j ¡}|j ¡}|j}|j|||dS)zd
        Return a copy of the array.
 
        Returns
        -------
        IntervalArray
        rg)r[rar\r`ror—rUrUrXra s
 
zIntervalArray.copycCs
t|jƒSru)r5r[rVrUrUrXr5szIntervalArray.isnarTrl)Úperiodsr¯rScCs¼t|ƒr|dkr| ¡S| |¡tt|ƒt|ƒƒ}t|ƒrnddlm}||jddj    }t
  |g|d¡}n|  |g|¡}|dkrš|}|d| …}n|t|ƒd…}|}|  ||g¡S)NrráFrxrT)r†rarÝrÛÚabsr5rârEr[rµrHrˆrƒrí)rWrîr¯Z    empty_lenrEr±ÚaÚbrUrUrXÚshifts
 zIntervalArray.shift)r®r¯rÖ)rWr®rSc
KsVt d|¡|}}|r&| |¡\}}t|j|||d}t|j|||d}    | ||    ¡S)am
        Take elements from the IntervalArray.
 
        Parameters
        ----------
        indices : sequence of integers
            Indices to be taken.
 
        allow_fill : bool, default False
            How to handle negative values in `indices`.
 
            * False: negative values in `indices` indicate positional indices
              from the right (the default). This is similar to
              :func:`numpy.take`.
 
            * True: negative values in `indices` indicate
              missing values. These values are set to `fill_value`. Any other
              other negative values raise a ``ValueError``.
 
        fill_value : Interval or NA, optional
            Fill value to use for NA-indices when `allow_fill` is True.
            This may be ``None``, in which case the default NA value for
            the type, ``self.dtype.na_value``, is used.
 
            For many ExtensionArrays, there will be two representations of
            `fill_value`: a user-facing "boxed" scalar, and a low-level
            physical NA value. `fill_value` should be the user-facing version,
            and the implementation should handle translating that to the
            physical version for processing the take if necessary.
 
        axis : any, default None
            Present for compat with IntervalIndex; does nothing.
 
        Returns
        -------
        IntervalArray
 
        Raises
        ------
        IndexError
            When the indices are out of bounds for the array.
        ValueError
            When `indices` contains negative values other than ``-1``
            and `allow_fill` is True.
        rUr­)rÐZ validate_takerÝr8r[r\r˜)
rWÚindicesr®r¯rÖrÓZ    fill_leftZ
fill_rightZ    left_takeZ
right_takerUrUrXr87s"6 ÿÿzIntervalArray.takec
CsÀz(t|ƒ}|j|dd|j|j}}Wn<tk
rd}zdt|ƒ›d}t|ƒ|‚W5d}~XYnXz|j |¡Wn@ttfk
r¶}zdt|ƒ›d}t|ƒ|‚W5d}~XYnX||fS)Nr§©rNz('value' should be an interval type, got z     instead.z2'value' should be a compatible interval type, got )rHÚ_check_closed_matchesrqrrrjr}Ú_validate_fill_valuer")rWr§r?r¨r©r”rsrUrUrXÚ_validate_listlike|sÿz IntervalArray._validate_listlikecCsTt|tƒr(|j|dd|j|j}}n$t||jjƒrD|jj}}ntdƒ‚||fS)Nr§rôz=can only insert Interval objects and NA into an IntervalArray)    rhrrõrqrrr4r`rµrj)rWr§rqrrrUrUrXrݒs
ÿzIntervalArray._validate_scalarcCsˆt||jjƒr6|jj}t|jjƒr*tdƒ‚||}}nJt|tƒrv|j    |dd|j|j
}}|j  |¡|j  |¡n
|  |¡S||fS)Nz4Cannot set float NaN to integer-backed IntervalArrayr§rô) r4rqr`rµr'rzrjrhrrõrrrör÷)rWr§r¨r©rUrUrXr¦ s  
 
z%IntervalArray._validate_setitem_valuerF)ÚdropnarScCstt |¡|dS)a2
        Returns a Series containing counts of each interval.
 
        Parameters
        ----------
        dropna : bool, default True
            Don't include counts of NaN.
 
        Returns
        -------
        counts : Series
 
        See Also
        --------
        Series.value_counts
        )rø)r:rŽr)rWrørUrUrXr:·szIntervalArray.value_countsc
s&t|ƒ}ttdƒp|ddƒ}t‰|dkr0d}nò|dkrRˆ|dƒ}d|›d}nÐ|dkr†ˆ|dƒ}ˆ|d    ƒ}d|›d
|›d}nœ||krút|ddƒ}‡fd d „|d|…Dƒ}‡fd d „|| d…Dƒ}d
 |¡}d
 |¡}    d|›d|    ›d}n(‡fdd „|Dƒ}d
 |¡}    d|    ›d}|S)Nzdisplay.max_seq_itemsé
rz[]rTú[ú]ér‰z, csg|] }ˆ|ƒ‘qSrUrU©rèÚx©Ú    formatterrUrXrêâsz.IntervalArray._format_data.<locals>.<listcomp>csg|] }ˆ|ƒ‘qSrUrUrýrÿrUrXrêãsz ... csg|] }ˆ|ƒ‘qSrUrUrýrÿrUrXrêès)r†rÛr r~Újoin)
rWÚnZ max_seq_itemsrPÚfirstrËÚheadÚtailZhead_strZtail_strrUrÿrXÚ _format_dataÎs.   
 
 
 zIntervalArray._format_datacCs<| ¡}dt|ƒj›d}|›|›dt|ƒ›d|j›}|S)Nú<z>
z    
Length: z    , dtype: )rr}rir†r`)rWrpÚ
class_nameÚtemplaterUrUrXÚ__repr__îszIntervalArray.__repr__cCs dtt|ƒjƒd}d|›S)Nú rTÚ
)r†r}ri)rWÚspacerUrUrXÚ _format_spaceøszIntervalArray._format_spacecCsddlm}||jddS)z^
        Return the left endpoints of each Interval in the IntervalArray as an Index.
        rráFrx)rârEr[©rWrErUrUrXrqÿs zIntervalArray.leftcCsddlm}||jddS)z_
        Return the right endpoints of each Interval in the IntervalArray as an Index.
        rráFrx)rârEr\rrUrUrXrrs zIntervalArray.rightrEcCs |j|jS)zT
        Return an Index with entries denoting the length of each Interval.
        )rrrqrVrUrUrXÚlengthszIntervalArray.lengthcCs<zd|j|jWStk
r6|jd|jYSXdS)zX
        Return the midpoint of each Interval in the IntervalArray as an Index.
        gà?N)rqrrrjrrVrUrUrXÚmidszIntervalArray.midaI
        Check elementwise if an Interval overlaps the values in the %(klass)s.
 
        Two intervals overlap if they share a common point, including closed
        endpoints. Intervals that only have an open endpoint in common do not
        overlap.
 
        Parameters
        ----------
        other : %(klass)s
            Interval to check against for an overlap.
 
        Returns
        -------
        ndarray
            Boolean array positionally indicating where an overlap occurs.
 
        See Also
        --------
        Interval.overlaps : Check whether two Interval objects overlap.
 
        Examples
        --------
        %(examples)s
        >>> intervals.overlaps(pd.Interval(0.5, 1.5))
        array([ True,  True, False])
 
        Intervals that share closed endpoints overlap:
 
        >>> intervals.overlaps(pd.Interval(1, 3, closed='left'))
        array([ True,  True, True])
 
        Intervals that only have an open endpoint in common do not overlap:
 
        >>> intervals.overlaps(pd.Interval(1, 2, closed='right'))
        array([False,  True, False])
        Úoverlapszö        >>> data = [(0, 1), (1, 3), (2, 4)]
        >>> intervals = pd.arrays.IntervalArray.from_tuples(data)
        >>> intervals
        <IntervalArray>
        [(0, 1], (1, 3], (2, 4]]
        Length: 3, dtype: interval[int64, right]
        )rLrQcCsxt|ttfƒrt‚t|tƒs4dt|ƒj›}t|ƒ‚|jrD|j    rDt
nt }|jrX|j    rXt
nt }||j |j ƒ||j |j ƒ@S)Nz#`other` must be Interval-like, got )rhrHr2ÚNotImplementedErrorrr}rirjZ closed_leftZ closed_rightrrrqrr)rWr½rsZop1Zop2rUrUrXrKs
zIntervalArray.overlapsrcCs|jjS)zƒ
        String describing the inclusive side the intervals.
 
        Either ``left``, ``right``, ``both`` or ``neither``.
        )r`rerVrUrUrXremszIntervalArray.closedaZ
        Return an identical %(klass)s closed on the specified side.
 
        Parameters
        ----------
        closed : {'left', 'right', 'both', 'neither'}
            Whether the intervals are closed on the left-side, right-side, both
            or neither.
 
        Returns
        -------
        %(klass)s
 
        %(examples)s        Ú
set_closedav        Examples
        --------
        >>> index = pd.arrays.IntervalArray.from_breaks(range(4))
        >>> index
        <IntervalArray>
        [(0, 1], (1, 2], (2, 3]]
        Length: 3, dtype: interval[int64, right]
        >>> index.set_closed('both')
        <IntervalArray>
        [[0, 1], [1, 2], [2, 3]]
        Length: 3, dtype: interval[int64, both]
        )rWrerScCsF|tkrd|›}t|ƒ‚|j|j}}t|j|d}|j|||dS)Nzinvalid option for 'closed': rdrg)rr|r[r\r/r`ro)rWrersrqrrr`rUrUrXrˆs 
zIntervalArray.set_closedzç
        Return a boolean whether the %(klass)s is non-overlapping and monotonic.
 
        Non-overlapping means (no Intervals share points), and monotonic means
        either monotonic increasing or monotonic decreasing.
        Úis_non_overlapping_monotoniccCs’|jdkrNt|jdd…|jdd…k ¡pJ|jdd…|jdd…k ¡ƒSt|jdd…|jdd…k ¡pŽ|jdd…|jdd…k ¡ƒS)NZbothr‰rT)rer^r\r[r–rVrUrUrXr¯s
 þ þz*IntervalArray.is_non_overlapping_monotoniczNpDtype | Nonec    Csj|j}|j}| ¡}|j}tjt|ƒtd}t|ƒD]0\}}||rPtj    ||<q4t
||||ƒ||<q4|S)zt
        Return the IntervalArray's data as a numpy array of Interval
        objects (with dtype='object')
        rg) r[r\r5rerŽr±r†rlr¼rr)    rWr`rqrrr¿rervrÀZ
left_valuerUrUrXÚ    __array__Ês zIntervalArray.__array__c
 
Cspddl}ddlm}z| |jj¡}Wn8tk
r^}ztd|jj›dƒ|‚W5d}~XYnX|||jƒ}|jj    |j
|j |dd|j
|j |ddgdd    gd
}|  ¡}| ¡rð| 
|¡ ¡d }    |jj|jt|ƒ|    g| d¡| d ¡gd }|dk    rb| |j¡r |St||ƒrR| |¡sbtd |jj›d|j›d|j›d|j›d    ƒ‚ntd|›dƒ‚|j ||¡S)z6
        Convert myself into a pyarrow Array.
        rN)ÚArrowIntervalTypez"Conversion to arrow with subtype 'z' is not supportedT)r}Z from_pandasrqrr)ÚnamesrT)ÚchildrenzINot supported to convert IntervalArray to type with different 'subtype' (z vs z) and 'closed' (z ) attributesz+Not supported to convert IntervalArray to 'z' type)ÚpyarrowZ(pandas.core.arrays.arrow.extension_typesrZfrom_numpy_dtyper`rzrjreZ StructArrayr‹r?r[r\r5rÙÚbuffersZ from_buffersr}r†ÚfieldråZ storage_typerhr;Z from_storage)
rWr}rrrzr”Z interval_typeZ storage_arrayr¿Z null_bitmaprUrUrXÚ__arrow_array__ÜsL ÿý þûü
  &ÿ
ÿzIntervalArray.__arrow_array__ak
        Return an %(return_type)s of tuples of the form (left, right).
 
        Parameters
        ----------
        na_tuple : bool, default True
            Returns NA as a tuple if True, ``(nan, nan)``, or just as the NA
            value itself if False, ``nan``.
 
        Returns
        -------
        tuples: %(return_type)s
        %(examples)s        Ú    to_tuplesr¤)Ú return_typerQ)Úna_tuplerScCs2t t|j|jƒ¡}|s.t | ¡|tj¡}|Sru)    ÚcomZasarray_tuplesafeÚzipr[r\rŽÚwherer5r)rWr ZtuplesrUrUrXr!szIntervalArray.to_tuplesznpt.NDArray[np.bool_])r¿rScCs‚| |¡\}}t|jtjƒrPt |j||¡t|jtjƒs>t‚t |j||¡n.|j ||¡t|jtjƒrpt‚|j ||¡dSru)    r¦rhr[rŽr¤Zputmaskr\ÚAssertionErrorÚ_putmask)rWr¿r§r¨r©rUrUrXr%-szIntervalArray._putmaskr)rWÚlocÚitemrScCs6| |¡\}}|j ||¡}|j ||¡}| ||¡S)ac
        Return a new IntervalArray inserting new item at location. Follows
        Python numpy.insert semantics for negative values.  Only Interval
        objects and NA can be inserted into an IntervalIndex
 
        Parameters
        ----------
        loc : int
        item : Interval
 
        Returns
        -------
        IntervalArray
        )rÝrqÚinsertrrr˜)rWr&r'Z left_insertZ right_insertrãrärUrUrXr(9szIntervalArray.insertcCsvt|jtjƒr>t |j|¡}t|jtjƒs.t‚t |j|¡}n*|j |¡}t|jtjƒr\t‚|j |¡}|j||dS)N©rqrr)rhr[rŽr¤Údeleter\r$r˜)rWr&rãrärUrUrXr*Os  zIntervalArray.deleteÚrepeatzint | Sequence[int])rWÚrepeatsrÖrScCs6t dd|i¡|j |¡}|j |¡}|j||dS)NrUrÖr))rÐZvalidate_repeatrqr+rrr˜)rWr,rÖZ left_repeatZ right_repeatrUrUrXr+Zs  zIntervalArray.repeata¼
        Check elementwise if the Intervals contain the value.
 
        Return a boolean mask whether the value is contained in the Intervals
        of the %(klass)s.
 
        Parameters
        ----------
        other : scalar
            The value to check whether it is contained in the Intervals.
 
        Returns
        -------
        boolean array
 
        See Also
        --------
        Interval.contains : Check whether Interval object contains value.
        %(klass)s.overlaps : Check if an Interval overlaps the values in the
            %(klass)s.
 
        Examples
        --------
        %(examples)s
        >>> intervals.contains(0.5)
        array([ True, False, False])
    ÚcontainszÞ        >>> intervals = pd.arrays.IntervalArray.from_tuples([(0, 1), (1, 3), (2, 4)])
        >>> intervals
        <IntervalArray>
        [(0, 1], (1, 3], (2, 4]]
        Length: 3, dtype: interval[int64, right]
        cCsFt|tƒrtdƒ‚|jr"|j|kn|j|k|jr:||jkn||jk@S)Nz*contains not implemented for two intervals)rhrrZ    open_leftr[Z
open_rightr\rÄrUrUrXr-ƒs
 
ÿzIntervalArray.containscCs¶t|dƒst |¡}t|dd}t|jƒr |j|jkrFtj|jt    dSt
|j|jƒrx|j   d¡}|j   d¡}t  ||¡St|jjƒt|jjƒAr tj|jt    dSt| t¡| t¡ƒS)Nr`TrcrgÚ
complex128)ÚhasattrrŽr?rAr(r`rer»r²r^r%Ú    _combinedÚviewZin1dr-rqr7r{rl)rWr„rqrrrUrUrXr7šs
 
 
     ÿzIntervalArray.isincCsT|jj dd¡}|jj dd¡}t|jƒr>|j||gdd}ntj||gdd}|S)Nr‰rT)rÖ)    rqZ_valuesÚreshaperrr-r`rírŽrì)rWrqrrÚcombrUrUrXr0ºs 
zIntervalArray._combined)ÚcombinedrScCsÖ| d¡ dd¡}|jj}t|ƒrŒt|jttfƒs6t‚t    |jƒj
|dd…df|d}t|j ttfƒsjt‚t    |j ƒj
|dd…df|d}n<t|t jƒsœt‚|dd…df |¡}|dd…df |¡}|j ||dS)    zY
        Create a new IntervalArray with our dtype from a 1D complex128 ndarray.
        Úi8r‰rüNrrgrTr))r1r2r[r`r-rhr=r>r$r}rƒr\rŽr˜)rWr4Úncr`rãrärUrUrXÚ_from_combinedÄs "zIntervalArray._from_combinedcCs6t|j d¡dd…dfƒ}|dd…df}| |¡S)Nr.r)r9r0r1r7)rWr6rUrUrXr9Ös
ÿzIntervalArray.unique)NNFT)NFN)rrFN)rrFN)rrFN)NNN)T)rTN)T)N)N)T)N)SriÚ
__module__Ú __qualname__Z can_hold_narŽrrµr¥ÚpropertyrYÚ__annotations__rtÚ classmethodrormrƒr‡ÚtextwrapÚdedentrJr!rˆr‹rŒrnr˜r`ršr›ržrŸr r£rªrÂrDrÃrÅrÆrÇrÈrÉrÒrÛrÜrÞr{rårírar5ròr8r÷rÝr¦r:rr
rrqrrrrrrerÚ_shared_docs_kwargsrrrrr%r(r*r<r+r-r7r0r7r9Ú __classcell__rUrUrÔrXrHºs°
 
ú3 úUû    
ÿÿýÿÿû ÿ2ÿýÿÿúÿ!ÿýÿÿû O
 
 
 
 
 
ûÿ(=
  úE 
 
 
 
ÿ(ÿþÿÿ
ÿÿþÿÿ þÿ    
ÿ
6þÿÿ      ý
ÿÿþÿÿ
     rrRcCs¶t|ttfƒr*t|ƒdkr*tjgtjdSt|ƒr<t|tƒr@|St    |ƒrTt 
|¡}n*t |dƒsrt|ttt fƒsr|St |dd}t |dƒs²t 
|¡}t|ƒr²|jtjkr²| tj¡}|S)a®
    Try to do platform conversion, with special casing for IntervalArray.
    Wrapper around maybe_convert_platform that alters the default return
    dtype in certain cases to be compatible with IntervalArray.  For example,
    empty lists return with integer dtype instead of object dtype, which is
    prohibited for IntervalArray.
 
    Parameters
    ----------
    values : array-like
 
    Returns
    -------
    array
    rrgr`Trc)rhÚlistrr†rŽr?Úint64r)r0r$rr/ÚrangerAr'r`r{)r„rUrUrXrkàs  
 
 rk)qÚ
__future__rr¶rrr=Útypingrrrrr    r
r r ÚnumpyrŽZpandas._configr Z pandas._libsrZpandas._libs.intervalrrrrZpandas._libs.missingrZpandas._typingrrrrrrrrrrrZpandas.compat.numpyrrÐZ pandas.errorsr Zpandas.util._decoratorsr!Zpandas.core.dtypes.castr"r#Zpandas.core.dtypes.commonr$r%r&r'r(r)r*r+r,r-r.Zpandas.core.dtypes.dtypesr/Zpandas.core.dtypes.genericr0r1r2r3Zpandas.core.dtypes.missingr4r5r6Zpandas.core.algorithmsr7r8r9r:Zpandas.core.arrays.baser;r<Zpandas.core.arrays.datetimesr=Zpandas.core.arrays.timedeltasr>Zpandas.core.commonÚcoreÚcommonr!Zpandas.core.constructionr?r°r@rAZpandas.core.indexersrBZpandas.core.opsrCrDrârErFrGr¤rZÚfloatr rJr;r?r>rHrkrUrUrUrXÚ<module>sŠ (    4   4       ý    þÿ?ÿùÿÿ