o
    5c'                     @  s  d Z ddlmZ ddlmZmZ ddlZddlmZm	Z	m
Z
 ddlZddlmZ ddlmZmZmZ ddlmZmZmZmZ dd	lmZmZmZmZ dd
lmZ ddlm Z m!Z! ddl"m#Z# ddl$m%Z%m&Z&m'Z'm(Z( ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z< ddl=m>Z>m?Z? ddl@mA  mBZC ddlDmEZE ddlFmA  mG  mHZI ddlFmJZJmKZKmLZLmMZM ddlNmOZOmPZP ddlQmRZRmSZS ddlTmUZU ddlVmWZWmXZX eYeIjZZZeZ[ddde\dd dd Z]dd  Z^d!d" Z_e e?d# dd$eZd% d&d'd(e\d)d* eSd+d,ge>d-d.eSg d/e>eSd0d1ge>d-d2G d3d deRZ`d?d6d7Zad?d8d9Zb						:d@dAd=d>ZcdS )Bz define the IntervalIndex     )annotations)leltN)AnyHashableLiteral)lib)IntervalIntervalMixinIntervalTree)
BaseOffset	Timedelta	Timestamp	to_offset)DtypeDtypeObjIntervalClosedTypenpt)InvalidIndexError)Appendercache_readonly)rewrite_exception)find_common_typeinfer_dtype_from_scalarmaybe_box_datetimelikemaybe_downcast_numeric)ensure_platform_intis_datetime64tz_dtypeis_datetime_or_timedelta_dtypeis_dtype_equalis_floatis_float_dtype
is_integeris_integer_dtypeis_interval_dtypeis_list_like	is_numberis_object_dtype	is_scalar)IntervalDtype)is_valid_na_for_dtypeunique)IntervalArray_interval_shared_docs)is_valid_positional_slice)Index_index_shared_docsensure_indexmaybe_extract_name)DatetimeIndex
date_range)ExtensionIndexinherit_names)
MultiIndex)TimedeltaIndextimedelta_rangeIntervalIndexz"IntervalIndex or list of IntervalszX         name : object, optional
              Name to be stored in the index.
         )klassqualnametarget_klassnamec                 C  s~   t | dt| }t| ttfrd}t|st|r!| tdd S t	|r)| d S t
|r4t| tjS tdtt|  Ndtype
datetime64   nsz%cannot determine next label for type getattrtype
isinstancer   r   r   r   nptimedelta64r#   r!   	nextafterinfty	TypeErrorreprlabelrA    rQ   R/var/www/html/gps/gps/lib/python3.10/site-packages/pandas/core/indexes/interval.py_get_next_labelo   s   rS   c                 C  s   t | dt| }t| ttfrd}t|st|r!| tdd S t	|r)| d S t
|r5t| tj S tdtt|  r@   rE   rO   rQ   rQ   rR   _get_prev_label}   s   rT   c                 C  s   | j di |S )zv
    This is called upon unpickling, rather than the default which doesn't have
    arguments and breaks __new__.
    NrQ   )from_arrays)clsdrQ   rQ   rR   _new_IntervalIndex   s   rX   classz>Immutable index of intervals that are closed on the same side.r?   z0.20.0zis_overlapping
values
 a7      Examples
    --------
    A new ``IntervalIndex`` is typically constructed using
    :func:`interval_range`:

    >>> pd.interval_range(start=0, end=5)
    IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]],
                  dtype='interval[int64, right]')

    It may also be constructed using one of the constructor
    methods: :meth:`IntervalIndex.from_arrays`,
    :meth:`IntervalIndex.from_breaks`, and :meth:`IntervalIndex.from_tuples`.

    See further examples in the doc strings of ``interval_range`` and the
    mentioned constructor methods.
    )r<   summaryr?   versionaddedextra_attributesextra_methodsexamples
set_closed	to_tuplesT)wrap)	__array__overlapscontainsclosed_leftclosed_right	open_left
open_rightis_emptyis_non_overlapping_monotonicclosed)cachec                      s  e Zd ZU dZded< ded< ded< ded< ded< ded	< d
ed< d
ed< dZeZ					ddddZe	e
ed d edd 				ddddZe	e
ed  d ed!d 				ddd"d#Ze	e
ed$ d ed%d 				ddd'd(Zedd*d+Zdd.d/Zedd1d2Zd3d4 Zedd5d6Ze
ejjddd9d:Zedd;d<Zedd=d>Zedd?d@ZddAdBZdCdD ZdddHdIZ 	dddMdNZ!			dddVdWZ"e
e#dX e$ ddZd[Z%dd\d]Z&dd^d_Z'edd`daZ(dbZ)dd fdfdgZ*eddhdiZ+e,j-fddjdkZ.ddmdnZ/eddodpZ0eddqdrZ1eddsdtZ2eddudvZ3ddzd{Z4d|dd}d fddZ5ddddZ6dd Z7dddZ8dddZ9dddZ:dd Z;  Z<S )r;   intervalindexr   rl   boolrk   rf   rg   rh   ri   r-   _data_valuesFNTrA   Dtype | Nonecopyr?   r   verify_integrityreturnc                 C  sV   t ||| }td| j t|||||d}W d    n1 s w   Y  | ||S )Nr-   )rl   rs   rA   rt   )r3   r   __name__r-   _simple_new)rV   datarl   rA   rs   r?   rt   arrayrQ   rQ   rR   __new__   s   
	zIntervalIndex.__new__from_breaksz        Examples
        --------
        >>> pd.IntervalIndex.from_breaks([0, 1, 2, 3])
        IntervalIndex([(0, 1], (1, 2], (2, 3]],
                      dtype='interval[int64, right]')
        )r<   r_   rightIntervalClosedType | Nonec                 C  L   t d| j tj||||d}W d    n1 sw   Y  | j||dS Nr-   )rl   rs   rA   r?   )r   rv   r-   r{   rw   )rV   breaksrl   r?   rs   rA   ry   rQ   rQ   rR   r{      s   zIntervalIndex.from_breaksrU   z        Examples
        --------
        >>> pd.IntervalIndex.from_arrays([0, 1, 2], [1, 2, 3])
        IntervalIndex([(0, 1], (1, 2], (2, 3]],
                      dtype='interval[int64, right]')
        c                 C  sN   t d| j tj|||||d}W d    n1 sw   Y  | j||dS )Nr-   )rs   rA   r   )r   rv   r-   rU   rw   )rV   leftr|   rl   r?   rs   rA   ry   rQ   rQ   rR   rU     s   
zIntervalIndex.from_arraysfrom_tuplesz        Examples
        --------
        >>> pd.IntervalIndex.from_tuples([(0, 1), (1, 2)])
        IntervalIndex([(0, 1], (1, 2]],
                       dtype='interval[int64, right]')
        strc                 C  r~   r   )r   rv   r-   r   rw   )rV   rx   rl   r?   rs   rA   arrrQ   rQ   rR   r   '  s   zIntervalIndex.from_tuplesr   c                 C  s(   |  | j}|  | j}t||| jdS )Nrl   )_maybe_convert_i8r   r|   r   rl   )selfr   r|   rQ   rQ   rR   _engineF  s   zIntervalIndex._enginekeyr   c                 C  sN   t | t|tst|| jr| jS dS z| | W dS  ty&   Y dS w )z
        return a boolean if this key is IN the index
        We *only* accept an Interval

        Parameters
        ----------
        key : Interval

        Returns
        -------
        bool
        FT)hashrH   r	   r*   rA   hasnansget_locKeyError)r   r   rQ   rQ   rR   __contains__L  s   

zIntervalIndex.__contains__r8   c                 C  s   t j| j| jgddgdS )Nr   r|   )names)r8   rU   r   r|   r   rQ   rQ   rR   _multiindexe  s   zIntervalIndex._multiindexc                 C  s(   | j | j| j| jd}tt| |fd fS )N)r   r|   rl   r?   )r   r|   rl   r?   rX   rG   )r   rW   rQ   rQ   rR   
__reduce__i  s   zIntervalIndex.__reduce__c                 C  s   dS )z4Return a string of the type inferred from the valuesintervalrQ   r   rQ   rQ   rR   inferred_typer  s   zIntervalIndex.inferred_typedeepintc                 C  s   | j j|d| jj|d S )N)r   )r   memory_usager|   )r   r   rQ   rQ   rR   r   w  s   zIntervalIndex.memory_usagec                 C  s   | ddd j S )z
        Return True if the IntervalIndex is monotonic decreasing (only equal or
        decreasing values), else False
        N)is_monotonic_increasingr   rQ   rQ   rR   is_monotonic_decreasing  s   z%IntervalIndex.is_monotonic_decreasingc                 C  s   | j }| j}|   dkrdS |js|jrdS t }t|jddd }|D ]}|| || f}||v r9 dS |	| q(dS )zX
        Return True if the IntervalIndex contains unique elements, else False.
        rC   FT)keepr   )
r   r|   isnasum	is_uniquesetrI   where
duplicatedadd)r   r   r|   
seen_pairs	check_idxidxpairrQ   rQ   rR   r     s   zIntervalIndex.is_uniquec                 C  s   | j jS )a  
        Return True if the IntervalIndex has overlapping intervals, else False.

        Two intervals overlap if they share a common point, including closed
        endpoints. Intervals that only have an open endpoint in common do not
        overlap.

        Returns
        -------
        bool
            Boolean indicating if the IntervalIndex has overlapping intervals.

        See Also
        --------
        Interval.overlaps : Check whether two Interval objects overlap.
        IntervalIndex.overlaps : Check an IntervalIndex elementwise for
            overlaps.

        Examples
        --------
        >>> index = pd.IntervalIndex.from_tuples([(0, 2), (1, 3), (4, 5)])
        >>> index
        IntervalIndex([(0, 2], (1, 3], (4, 5]],
              dtype='interval[int64, right]')
        >>> index.is_overlapping
        True

        Intervals that share closed endpoints overlap:

        >>> index = pd.interval_range(0, 3, closed='both')
        >>> index
        IntervalIndex([[0, 1], [1, 2], [2, 3]],
              dtype='interval[int64, both]')
        >>> index.is_overlapping
        True

        Intervals that only have an open endpoint in common do not overlap:

        >>> index = pd.interval_range(0, 3, closed='left')
        >>> index
        IntervalIndex([[0, 1), [1, 2), [2, 3)],
              dtype='interval[int64, left]')
        >>> index.is_overlapping
        False
        )r   is_overlappingr   rQ   rQ   rR   r     s   0zIntervalIndex.is_overlappingc                 C  s4   t |s	t|tr| |jS ttttf}t||S )a	  
        Check if a given key needs i8 conversion. Conversion is necessary for
        Timestamp, Timedelta, DatetimeIndex, and TimedeltaIndex keys. An
        Interval-like requires conversion if its endpoints are one of the
        aforementioned types.

        Assumes that any list-like data has already been cast to an Index.

        Parameters
        ----------
        key : scalar or Index-like
            The key that should be checked for i8 conversion

        Returns
        -------
        bool
        )	r$   rH   r	   _needs_i8_conversionr   r   r   r4   r9   )r   r   i8_typesrQ   rQ   rR   r     s   
z"IntervalIndex._needs_i8_conversionc           
      C  s  |}t |r
t|}| |s|S t|}t|st|tr9| |j}| |j	}|r.tnt
j}|||| jdS |rdt|dd\}}t|rL|j}n+t|trU|j}n"t|tjtjfrc|d}n|jt|j}}|jrw||j }| jj}	t|	|std|	 d| |S )a  
        Maybe convert a given key to its equivalent i8 value(s). Used as a
        preprocessing step prior to IntervalTree queries (self._engine), which
        expects numeric data.

        Parameters
        ----------
        key : scalar or list-like
            The key that should maybe be converted to i8.

        Returns
        -------
        scalar or list-like
            The original key if no conversion occurred, int if converted scalar,
            Int64Index if converted list-like.
        r   T)pandas_dtypei8z)Cannot index an IntervalIndex of subtype z with values of dtype ) r%   r2   r   r(   r$   rH   r	   r   r   r|   r;   rU   rl   r   r   	is_periodordinalr   valuerI   rB   rJ   viewrA   r0   asi8r   r   _isnansubtyper   
ValueError)
r   r   originalscalarr   r|   constructor	key_dtypekey_i8r   rQ   rQ   rR   r     sB   




zIntervalIndex._maybe_convert_i8r   sideLiteral['left', 'right']c                 C  sz   | j stdt|ttfrtd|dkr| jjs"|dkr-| jjs-| j}| j	r,t
|}n
| j}| jr7t|}|||S )Nzrcan only get slices from an IntervalIndex if bounds are non-overlapping and all monotonic increasing or decreasingz,Interval objects are not currently supportedr   r|   )rk   r   rH   r
   r;   NotImplementedErrorr   r   r|   ri   rS   rh   rT   _searchsorted_monotonic)r   rP   r   sub_idxrQ   rQ   rR   r   *  s&   z%IntervalIndex._searchsorted_monotonicmethod
str | Noneint | slice | np.ndarrayc           
   
   C  s"  |  | | | t|tr&| j|jkrt|| j|jk| j|jk@ }n9t|| j	r1| 
 }n.| jr6tnt}| jr=tnt}z|| j|||| j@ }W n ty^ } zt||d}~ww | }|dkrkt||dkrs| S t|d}	t|	tr|	jdu rt|	jt| |	j}	|	S )a1  
        Get integer location, slice or boolean mask for requested label.

        Parameters
        ----------
        key : label
        method : {None}, optional
            * default: matches where the label is within an interval only.

            .. deprecated:: 1.4

        Returns
        -------
        int if unique index, slice if monotonic index, else mask

        Examples
        --------
        >>> i1, i2 = pd.Interval(0, 1), pd.Interval(1, 2)
        >>> index = pd.IntervalIndex([i1, i2])
        >>> index.get_loc(1)
        0

        You can also supply a point inside an interval.

        >>> index.get_loc(1.5)
        1

        If a label is in several intervals, you get the locations of all the
        relevant intervals.

        >>> i3 = pd.Interval(0, 2)
        >>> overlapping_index = pd.IntervalIndex([i1, i2, i3])
        >>> overlapping_index.get_loc(0.5)
        array([ True, False,  True])

        Only exact matches will be returned if an interval is provided.

        >>> index.get_loc(pd.Interval(0, 1))
        0
        Nr   rC   u1)_check_indexing_method_check_indexing_errorrH   r	   rl   r   r   r|   r*   rA   r   rf   r   r   rg   rM   r   argmaxr   maybe_booleans_to_slicer   slicestopstartlenstep)
r   r   r   	tolerancemaskop_leftop_righterrmatchesresrQ   rQ   rR   r   G  s2   
+



zIntervalIndex.get_loctargetr0   limit
int | Noner   
Any | Nonenpt.NDArray[np.intp]c                 C  sT   t |tr| |}t
|S t|js#| |}| j|j}t
|S | 	|d S )Nr   )rH   r;   _get_indexer_unique_sidesr'   rA   r   r   get_indexervalues_get_indexer_pointwiser   )r   r   r   r   r   indexerrQ   rQ   rR   _get_indexer  s   



zIntervalIndex._get_indexerget_indexer_non_unique1tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]c                 C  s   t |}| |s| |s| j|d ddS t|tr6| jjr1| jjr1| 	|}|dk
 d }n"| |S t|js@| |sE| |S | |}| j|j\}}t|t|fS )NFr+   r   r   )r2   _should_compare_should_partial_index_get_indexer_non_comparablerH   r;   r   r   r|   r   nonzeror   r'   rA   r   r   r   r   r   )r   r   r   missingrQ   rQ   rR   r     s   




z$IntervalIndex.get_indexer_non_uniquec                 C  s2   | j |j }| j|j}t||k|d}|S )zZ
        _get_indexer specialized to the case where both of our sides are unique.
        r   )r   r   r|   rI   r   )r   r   left_indexerright_indexerr   rQ   rQ   rR   r     s   z'IntervalIndex._get_indexer_unique_sidesc              	   C  s   g g }}t |D ]^\}}z-| |}t|tr%tj|j|j|jdd}nt	
|r2tj|dd}nt|d }W n' tyN   || tdg}Y n tya   || tdg}Y nw || q	t|}t|t|fS )zV
        pointwise implementation for get_indexer and get_indexer_non_unique.
        intprA   rC   )ndminr   r   )	enumerater   rH   r   rI   aranger   r   r   r   r"   ry   r   r   appendr   concatenater   )r   r   r   r   ir   locsrQ   rQ   rR   r     s(   






z$IntervalIndex._get_indexer_pointwisec                 C  s   | j  o	| jjdk S )N   )r   r   	_na_countr   rQ   rQ   rR   _index_as_unique     zIntervalIndex._index_as_uniquezKcannot handle overlapping indices; use IntervalIndex.get_indexer_non_uniquer   kindis_framec                   sR   |j d u s |j dks d}|dkrt||dkr t|s t|t j|||dS )NrC   zClabel-based slicing with step!=1 is not supported for IntervalIndexlocgetitem)r   )r   r   r/   super_convert_slice_indexer)r   r   r   r   msg	__class__rQ   rR   r     s   z$IntervalIndex._convert_slice_indexerc                 C  s   | j jjdv S )N)mM)rA   r   r   r   rQ   rQ   rR   _should_fallback_to_positional  s   z,IntervalIndex._should_fallback_to_positionalc                 C  s    |  |dd t| |||S )Nr   _maybe_cast_slice_bound)_deprecated_argrF   r   )r   rP   r   r   rQ   rQ   rR   r     s   z%IntervalIndex._maybe_cast_slice_boundr   c                 C  s&   t |tsdS t| j|g}t| S )NF)rH   r)   r   rA   r'   )r   rA   common_subtyperQ   rQ   rR   _is_comparable_dtype  s   

z"IntervalIndex._is_comparable_dtypec                 C     t | jjddS NF)rs   )r0   rp   r   r   rQ   rQ   rR   r   !     zIntervalIndex.leftc                 C  r  r  )r0   rp   r|   r   rQ   rQ   rR   r|   %  r  zIntervalIndex.rightc                 C  r  r  )r0   rp   midr   rQ   rQ   rR   r  )  r  zIntervalIndex.midc                 C  r  r  )r0   rp   lengthr   rQ   rQ   rR   r  -  r  zIntervalIndex.lengthheader	list[str]na_repc                 C  s   |t | j|d S )N)r  )list_format_native_types)r   r	  r  rQ   rQ   rR   _format_with_header5  r   z!IntervalIndex._format_with_headerNaNr  quotingnpt.NDArray[np.object_]c                  s   t  jd||d|S )Nr  rQ   )r   r  )r   r  r  kwargsr   rQ   rR   r  9  s   z"IntervalIndex._format_native_typesc                 C  s   | j  d |   S )N,)rp   _format_data_format_space)r   r?   rQ   rQ   rR   r  ?  s   zIntervalIndex._format_datac                 C  sf   | j jr| jjr| |}n|j jr$|jjr$|   dkr$|| }n| |}|du r1| }|S )zL
        intersection specialized to the case with matching dtypes.
        rC   N)r   r   r|   _intersection_uniquer   r   _intersection_non_uniquesort_values)r   othersorttakenrQ   rQ   rR   _intersectionG  s    
zIntervalIndex._intersectionr  c                 C  sP   | j |j }| j|j}||k|dk@ }|| d }t|}| |S )a'  
        Used when the IntervalIndex does not have any common endpoint,
        no matter left or right.
        Return the intersection with another IntervalIndex.
        Parameters
        ----------
        other : IntervalIndex
        Returns
        -------
        IntervalIndex
        r   r   )r   r   r|   taker   r,   )r   r  lindexerrindexermatchr   rQ   rQ   rR   r  [  s   
z"IntervalIndex._intersection_uniquec                 C  s   t jt| td}| jr |jr t t| |   d }d||< tt|j	|j
}tt| j	| j
D ]\}}||v r>d||< q2| | S )a  
        Used when the IntervalIndex does have some common endpoints,
        on either sides.
        Return the intersection with another IntervalIndex.

        Parameters
        ----------
        other : IntervalIndex

        Returns
        -------
        IntervalIndex
        r   r   T)rI   zerosr   ro   r   r   r   r   zipr   r|   r   )r   r  r   first_nan_loc
other_tupsr   tuprQ   rQ   rR   r  q  s   z&IntervalIndex._intersection_non_unique
np.ndarrayc                 C     t d)NzRIntervalIndex does not use libjoin fastpaths or pass values to IndexEngine objectsr   r   rQ   rQ   rR   _get_engine_target  s   z IntervalIndex._get_engine_targetc                 C  r(  )Nz,IntervalIndex does not use libjoin fastpathsr)  )r   resultrQ   rQ   rR   _from_join_target  s   zIntervalIndex._from_join_target)NNFNT)
rA   rr   rs   ro   r?   r   rt   ro   ru   r;   )r|   NFN)
rl   r}   r?   r   rs   ro   rA   rr   ru   r;   )
rl   r   r?   r   rs   ro   rA   rr   ru   r;   )
rl   r   r?   r   rs   ro   rA   rr   ru   r;   )ru   r   )r   r   ru   ro   )ru   r8   )ru   r   )F)r   ro   ru   r   ru   ro   )r   )r   r   )NN)r   r   ru   r   )NNN)
r   r0   r   r   r   r   r   r   ru   r   )r   r0   ru   r   )r   r;   ru   r   )r   r   r   r   r   ro   )r   r   )rA   r   ru   ro   )ru   r0   )r	  r
  r  r   ru   r
  )ru   r  N)r  r;   ru   r;   )ru   r'  )=rv   
__module____qualname___typ__annotations___can_hold_stringsr-   	_data_clsrz   classmethodr   r.   textwrapdedentr{   rU   r   r   r   r   r   r   propertyr   r0   r   __doc__r   r   r   r   r   r   r   r   r1   _index_doc_kwargsr   r   r   r   _requires_unique_msgr   r   r   
no_defaultr   r  r   r|   r  r  r  r  r  r  r  r  r*  r,  __classcell__rQ   rQ   r   rR   r;      s   
 .
	

1AM

 




	ru   ro   c                 C  s$   t t| t| tt| t| du gS )zJ
    Helper for interval_range to check if start/end are valid types.
    N)anyr&   rH   r   r   )endpointrQ   rQ   rR   _is_valid_endpoint  s   r@  c                 C  sL   dd }dd }t | rt |p%|| o||p%|| o||p%t| |S )zK
    Helper for interval_range to check type compat of start/end/freq.
    c                 S     t | ttfS r.  )rH   r   r   xrQ   rQ   rR   <lambda>      z%_is_type_compatible.<locals>.<lambda>c                 S  rA  r.  )rH   r   r   rB  rQ   rQ   rR   rD    rE  )r&   comany_none)abis_ts_compatis_td_compatrQ   rQ   rR   _is_type_compatible  s   
rL  r|   r   r   c           	   
   C  s,  t | } t |}| dur| n|}|du r#t|| |r#t|r!dnd}t| |||dkr1tdt| s<td|  t|sGtd| t|rPt|}nt	|s_|dur_t
d| |durt|szt|}W n ty } ztd	| |d}~ww tt| |t| |t||gst
d
|dur|d7 }t|rt| ||r|||  | 8 }|du rt||  | d }n| du r||d |  } n|du r| |d |  }t| ||}tdd t| ||D rt|td}nt|trt| |||d}nt| |||d}tj|||dS )aP  
    Return a fixed frequency IntervalIndex.

    Parameters
    ----------
    start : numeric or datetime-like, default None
        Left bound for generating intervals.
    end : numeric or datetime-like, default None
        Right bound for generating intervals.
    periods : int, default None
        Number of periods to generate.
    freq : numeric, str, or DateOffset, default None
        The length of each interval. Must be consistent with the type of start
        and end, e.g. 2 for numeric, or '5H' for datetime-like.  Default is 1
        for numeric and 'D' for datetime-like.
    name : str, default None
        Name of the resulting IntervalIndex.
    closed : {'left', 'right', 'both', 'neither'}, default 'right'
        Whether the intervals are closed on the left-side, right-side, both
        or neither.

    Returns
    -------
    IntervalIndex

    See Also
    --------
    IntervalIndex : An Index of intervals that are all closed on the same side.

    Notes
    -----
    Of the four parameters ``start``, ``end``, ``periods``, and ``freq``,
    exactly three must be specified. If ``freq`` is omitted, the resulting
    ``IntervalIndex`` will have ``periods`` linearly spaced elements between
    ``start`` and ``end``, inclusively.

    To learn more about datetime-like frequency strings, please see `this link
    <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases>`__.

    Examples
    --------
    Numeric ``start`` and  ``end`` is supported.

    >>> pd.interval_range(start=0, end=5)
    IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]],
                  dtype='interval[int64, right]')

    Additionally, datetime-like input is also supported.

    >>> pd.interval_range(start=pd.Timestamp('2017-01-01'),
    ...                   end=pd.Timestamp('2017-01-04'))
    IntervalIndex([(2017-01-01, 2017-01-02], (2017-01-02, 2017-01-03],
                   (2017-01-03, 2017-01-04]],
                  dtype='interval[datetime64[ns], right]')

    The ``freq`` parameter specifies the frequency between the left and right.
    endpoints of the individual intervals within the ``IntervalIndex``.  For
    numeric ``start`` and ``end``, the frequency must also be numeric.

    >>> pd.interval_range(start=0, periods=4, freq=1.5)
    IntervalIndex([(0.0, 1.5], (1.5, 3.0], (3.0, 4.5], (4.5, 6.0]],
                  dtype='interval[float64, right]')

    Similarly, for datetime-like ``start`` and ``end``, the frequency must be
    convertible to a DateOffset.

    >>> pd.interval_range(start=pd.Timestamp('2017-01-01'),
    ...                   periods=3, freq='MS')
    IntervalIndex([(2017-01-01, 2017-02-01], (2017-02-01, 2017-03-01],
                   (2017-03-01, 2017-04-01]],
                  dtype='interval[datetime64[ns], right]')

    Specify ``start``, ``end``, and ``periods``; the frequency is generated
    automatically (linearly spaced).

    >>> pd.interval_range(start=0, end=6, periods=4)
    IntervalIndex([(0.0, 1.5], (1.5, 3.0], (3.0, 4.5], (4.5, 6.0]],
              dtype='interval[float64, right]')

    The ``closed`` parameter specifies which endpoints of the individual
    intervals within the ``IntervalIndex`` are closed.

    >>> pd.interval_range(end=5, periods=4, closed='both')
    IntervalIndex([[1, 2], [2, 3], [3, 4], [4, 5]],
                  dtype='interval[int64, both]')
    NrC   D   zVOf the four parameters: start, end, periods, and freq, exactly three must be specifiedz,start must be numeric or datetime-like, got z*end must be numeric or datetime-like, got zperiods must be a number, got z7freq must be numeric or convertible to DateOffset, got z+start, end, freq need to be type compatiblec                 s  s    | ]}t |V  qd S r.  )r"   ).0rC  rQ   rQ   rR   	<genexpr>V  s    z!interval_range.<locals>.<genexpr>int64)r   endperiodsfreq)r?   rl   )r   rF  rG  r&   count_not_noner   r@  r    r   r"   rM   r   allrL  all_not_nonerI   linspacenot_noner   rA   rH   r   r5   r:   r;   r{   )	r   rR  rS  rT  r?   rl   r?  r   r   rQ   rQ   rR   interval_range  sr   ^
rZ  r-  )NNNNNr|   )r?   r   rl   r   ru   r;   )dr9  
__future__r   operatorr   r   r6  typingr   r   r   numpyrI   pandas._libsr   pandas._libs.intervalr	   r
   r   pandas._libs.tslibsr   r   r   r   pandas._typingr   r   r   r   pandas.errorsr   pandas.util._decoratorsr   r   pandas.util._exceptionsr   pandas.core.dtypes.castr   r   r   r   pandas.core.dtypes.commonr   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   pandas.core.dtypes.dtypesr)   pandas.core.dtypes.missingr*   pandas.core.algorithmsr,   pandas.core.arrays.intervalr-   r.   pandas.core.commoncorecommonrF  pandas.core.indexersr/   pandas.core.indexes.baseindexesbaseibaser0   r1   r2   r3   pandas.core.indexes.datetimesr4   r5   pandas.core.indexes.extensionr6   r7   pandas.core.indexes.multir8   pandas.core.indexes.timedeltasr9   r:   dictr:  updater7  rS   rT   rX   r;   r@  rL  rZ  rQ   rQ   rQ   rR   <module>   s    <

     
d
