a
    Of.                  
   @  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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$m%Z% ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z:m;Z; ddl<m=  m>Z? ddl@mAZA ddlBm=  mC  mDZE ddlBmFZFmGZGmHZHmIZI ddlJmKZKmLZL ddlMmNZNmOZO ddlPmQZQ ddlRmSZSmTZT erddlUmVZV ddlWmXZXmYZYmZZZm[Z[m\Z\ e]eEj^Z^e^_ddde`dd dd  Zad!d" Zbd#d$ Zcee;d% dd&e^d' d(d)e`d*d+ eOd,d-ge:d.d/eOg d0e:eOd1d2ge:d.d3G d4d deNZdd5d6d7d8Zed5d6d9d:ZfdAd<d=dd>d?d@ZgdS )Bz define the IntervalIndex     )annotations)leltN)TYPE_CHECKINGAnyLiteral)lib)IntervalIntervalMixinIntervalTree)
BaseOffsetPeriod	Timedelta	Timestamp	to_offset)InvalidIndexError)Appendercache_readonly)rewrite_exception)find_common_typeinfer_dtype_from_scalarmaybe_box_datetimelikemaybe_downcast_numericmaybe_upcast_numeric_to_64bit)	ensure_platform_intis_float_dtype
is_integeris_integer_dtypeis_list_like	is_numberis_object_dtype	is_scalarpandas_dtype)DatetimeTZDtypeIntervalDtype)is_valid_na_for_dtypeunique)validate_periods)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)Hashable)DtypeDtypeObjIntervalClosedTypeSelfnptIntervalIndexz"IntervalIndex or list of IntervalszX         name : object, optional
              Name to be stored in the index.
         )klassqualnameZtarget_klassnamec                 C  s   t | dt| }t| ttfr"d}t|}t|ds@t|trP| t	
dd S t|r`| d S t|rvt	| t	jS tdtt|  d S Ndtypezdatetime64[ns]mM   nsz%cannot determine next label for type getattrtype
isinstancer   r   r"   r   Zis_np_dtyper#   nptimedelta64r   r   	nextafterinf	TypeErrorreprlabelrB    rR   U/var/www/ai-form-bot/venv/lib/python3.9/site-packages/pandas/core/indexes/interval.py_get_next_labelu   s    rT   c                 C  s   t | dt| }t| ttfr"d}t|}t|ds@t|trP| t	
dd S t|r`| d S t|rxt	| t	j S tdtt|  d S rA   rF   rP   rR   rR   rS   _get_prev_label   s    rU   c                 C  s   | j f i |S )zv
    This is called upon unpickling, rather than the default which doesn't have
    arguments and breaks __new__.
    )from_arrays)clsdrR   rR   rS   _new_IntervalIndex   s    rY   classz>Immutable index of intervals that are closed on the same side.r@   z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@   Zextra_attributesZextra_methodsexamplesZ
set_closedZ	to_tuplesT)wrap)Z	__array__overlapscontainsclosed_leftclosed_right	open_left
open_rightZis_emptyis_non_overlapping_monotonicclosed)cachec                	      sV  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ddddddddddZe	e
ed d ededd dddddd dddZe	e
ed d eded d dddddd dd!d"Ze	e
ed# d eded$d dddddd dd%d&Zed'd(d)d*Zd+dd,d-d.Zd/d d0d1d2Zed3d(d4d5Zd6d7 Zed8d(d9d:Ze
ejjddd;d<d=d>Zedd(d?d@Zedd(dAdBZedd(dCdDZdd(dEdFZdGdH Z ddJdKdLdMZ!dNd(dOdPZ"ddQdRdSdTdUdVdWdXZ#e
e$dY e% dQdZd[d\d]Z&d dUd[d^d_Z'dQdZd[d`daZ(edd(dbdcZ)ddZ*d/dedf fdgdhZ+edd(didjZ,d8dKdkdlZ-dmddndodpZ.edQd(dqdrZ/edQd(dsdtZ0edQd(dudvZ1edQd(dwdxZ2dydz Z3d d d{d|d}Z4d d d{d~dZ5dd(ddZ6dd Z7  Z8S )r=   Zintervalindexr:   rf   boolre   ra   rb   rc   rd   r)   _dataZ_valuesFNTzIntervalClosedType | NonezDtype | NoneHashable | Noner;   )rf   rB   copyr@   verify_integrityreturnc                 C  sV   t ||| }td| j" t|||||d}W d    n1 s@0    Y  | ||S )Nr)   )rf   rk   rB   rl   )r/   r   __name__r)   _simple_new)rW   datarf   rB   rk   r@   rl   arrayrR   rR   rS   __new__   s    	$zIntervalIndex.__new__from_breakszY
             name : str, optional
                  Name of the resulting IntervalIndex.z        Examples
        --------
        >>> pd.IntervalIndex.from_breaks([0, 1, 2, 3])
        IntervalIndex([(0, 1], (1, 2], (2, 3]],
                      dtype='interval[int64, right]')
        )r>   r@   r]   right)rf   r@   rk   rB   rm   c                 C  sL   t d| j" tj||||d}W d    n1 s40    Y  | j||dS Nr)   )rf   rk   rB   r@   )r   rn   r)   rs   ro   )rW   breaksrf   r@   rk   rB   rq   rR   rR   rS   rs      s
    $zIntervalIndex.from_breaksrV   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 s60    Y  | j||dS )Nr)   )rk   rB   rv   )r   rn   r)   rV   ro   )rW   leftrt   rf   r@   rk   rB   rq   rR   rR   rS   rV     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]')
        c                 C  sL   t d| j" tj||||d}W d    n1 s40    Y  | j||dS ru   )r   rn   r)   ry   ro   )rW   rp   rf   r@   rk   rB   ZarrrR   rR   rS   ry   ;  s    0zIntervalIndex.from_tuplesr   rm   c                 C  s8   |  | j}t|}|  | j}t|}t||| jdS )Nrf   )_maybe_convert_i8rx   r   rt   r   rf   )selfrx   rt   rR   rR   rS   _engine_  s
    zIntervalIndex._enginer   )keyrm   c                 C  sR   t | t|ts(t|| jr$| jS dS z| | W dS  tyL   Y dS 0 dS )z
        return a boolean if this key is IN the index
        We *only* accept an Interval

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

        Returns
        -------
        bool
        FTN)hashrI   r	   r%   rB   hasnansget_locKeyError)r}   r   rR   rR   rS   __contains__h  s    

zIntervalIndex.__contains__slice)slobjrm   c                 C  s   | j | }t| j|| jdS )zH
        Fastpath for __getitem__ when we know we have a slice.
        rv   )ri   rH   ro   _name)r}   r   resrR   rR   rS   _getitem_slice  s    
zIntervalIndex._getitem_slicer4   c                 C  s   t j| j| jgddgdS )Nrx   rt   )names)r4   rV   rx   rt   r}   rR   rR   rS   _multiindex  s    zIntervalIndex._multiindexc                 C  s(   | j | j| j| jd}tt| |fd fS )N)rx   rt   rf   r@   )rx   rt   rf   r@   rY   rH   )r}   rX   rR   rR   rS   
__reduce__  s    zIntervalIndex.__reduce__strc                 C  s   dS )z4Return a string of the type inferred from the valuesintervalrR   r   rR   rR   rS   inferred_type  s    zIntervalIndex.inferred_typeint)deeprm   c                 C  s   | j j|d| jj|d S )N)r   )rx   memory_usagert   )r}   r   rR   rR   rS   r     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   rR   rR   rS   is_monotonic_decreasing  s    z%IntervalIndex.is_monotonic_decreasingc                 C  s   | j }| j}|   dkr dS |js,|jr0dS t }t|jddd }|D ],}|| || f}||v rr dS |	| qPdS )zX
        Return True if the IntervalIndex contains unique elements, else False.
        rD   FT)Zkeepr   )
rx   rt   isnasum	is_uniquesetrJ   whereZ
duplicatedadd)r}   rx   rt   Z
seen_pairsZ	check_idxidxpairrR   rR   rS   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   rR   rR   rS   r     s    0zIntervalIndex.is_overlappingc                 C  sB   t |dd}t|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
        rB   N)
rG   rI   r$   r	   _needs_i8_conversionrx   r   r   r0   r5   )r}   r   	key_dtypeZi8_typesrR   rR   rS   r     s
    z"IntervalIndex._needs_i8_conversionc           	      C  s&  t |rt|}t|}| |s&|S t|}t|dd}t|tsNt|tr| 	|j
}| 	|j}|rntntj}|||| jdS |rt|\}}t|tr|j}qt|tr|j}qt|tjtjfr|d}n&|jt|j }}|jr||j }| jj}||kr"t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,
            Index with an int64 dtype if converted list-like.
        rB   Nr{   i8z)Cannot index an IntervalIndex of subtype z with values of dtype ) r   r.   r   r   r!   rG   rI   r$   r	   r|   rx   rt   r=   rV   rf   r   r   Zordinalr   _valuerJ   Z
datetime64rK   viewrB   r,   Zasi8r   r   Z_isnansubtype
ValueError)	r}   r   Zscalarr   rx   rt   constructorZkey_i8r   rR   rR   rS   r|     sB    



zIntervalIndex._maybe_convert_i8rx   zLiteral['left', 'right'])sidec                 C  sz   | j stdt|ttfr$td|dkr4| jjsD|dkrZ| jjsZ| j}| j	rnt
|}n| j}| jrnt|}|||S )Nzrcan only get slices from an IntervalIndex if bounds are non-overlapping and all monotonic increasing or decreasingz,Interval objects are not currently supportedrx   rt   )re   r   rI   r
   r=   NotImplementedErrorrx   r   rt   rd   rT   rc   rU   _searchsorted_monotonic)r}   rQ   r   Zsub_idxrR   rR   rS   r   P  s$    
z%IntervalIndex._searchsorted_monotoniczint | slice | np.ndarrayc              
   C  s(  |  | t|trB| j|jkr(t|| j|jk| j|jk@ }n~t|| jrX| 	 }nh| j
rbtnt}| jrptnt}z|| j|||| j@ }W n. ty } zt||W Y d}~n
d}~0 0 | }|dkrt||dkr| S t|d}t|tr$|jdu r$t|jt| |j}|S )a  
        Get integer location, slice or boolean mask for requested label.

        Parameters
        ----------
        key : label

        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   rD   u1)Z_check_indexing_errorrI   r	   rf   r   rx   rt   r%   rB   r   ra   r   r   rb   rN   r   Zargmaxr   Zmaybe_booleans_to_slicer   r   stopstartlenstep)r}   r   maskZop_leftZop_righterrmatchesr   rR   rR   rS   r   m  s,    %


 zIntervalIndex.get_locr,   z
str | Nonez
int | Nonez
Any | Noneznpt.NDArray[np.intp])targetmethodlimit	tolerancerm   c                 C  sP   t |tr| |}n2t|js:| |}| j|j}n| 	|d S t
|S )Nr   )rI   r=   _get_indexer_unique_sidesr    rB   r|   r~   get_indexervalues_get_indexer_pointwiser   )r}   r   r   r   r   indexerrR   rR   rS   _get_indexer  s    


zIntervalIndex._get_indexerget_indexer_non_uniquez1tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]])r   rm   c                 C  s   t |}| |s,| |s,| j|d ddS t|trn| jjrb| jjrb| 	|}|dk
 d }q| |S n:t|js| |s| |S | |}| j|j\}}t|t|fS )NFr&   r   r   )r.   Z_should_compareZ_should_partial_indexZ_get_indexer_non_comparablerI   r=   rx   r   rt   r   nonzeror   r    rB   r|   r~   r   r   r   )r}   r   r   missingrR   rR   rS   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   )rx   r   rt   rJ   r   )r}   r   Zleft_indexerZright_indexerr   rR   rR   rS   r     s    z'IntervalIndex._get_indexer_unique_sidesc              	   C  s   g g  }}t |D ]\}}zZ| |}t|trJtj|j|j|jdd}n(t	
|rdtj|dd}nt|d }W nN ty   || tdg}Y n( ty   || tdg}Y n0 || qt|}t|t|fS )zV
        pointwise implementation for get_indexer and get_indexer_non_unique.
        ZintprB   rD   )Zndminr   r   )	enumerater   rI   r   rJ   aranger   r   r   r   r   rq   r   r   appendr   Zconcatenater   )r}   r   r   r   ir   ZlocsrR   rR   rS   r     s$    






z$IntervalIndex._get_indexer_pointwisec                 C  s   | j  o| jjdk S )N   )r   r~   Z	_na_countr   rR   rR   rS   _index_as_unique  s    zIntervalIndex._index_as_uniquezKcannot handle overlapping indices; use IntervalIndex.get_indexer_non_uniquezLiteral['loc', 'getitem'])r   kindc                   sN   |j d u s@|j dks@d}|dkr(t||dkr@t|s@t|t ||S )NrD   zClabel-based slicing with step!=1 is not supported for IntervalIndexlocgetitem)r   r   r+   super_convert_slice_indexer)r}   r   r   msg	__class__rR   rS   r     s    z$IntervalIndex._convert_slice_indexerc                 C  s   | j jjdv S )NrC   )rB   r   r   r   rR   rR   rS   _should_fallback_to_positional+  s    z,IntervalIndex._should_fallback_to_positionalc                 C  s   t | |||S N)rG   _maybe_cast_slice_bound)r}   rQ   r   rR   rR   rS   r   3  s    z%IntervalIndex._maybe_cast_slice_boundr9   )rB   rm   c                 C  s&   t |tsdS t| j|g}t| S )NF)rI   r$   r   rB   r    )r}   rB   Zcommon_subtyperR   rR   rS   _is_comparable_dtype6  s    
z"IntervalIndex._is_comparable_dtypec                 C  s   t | jjddS NF)rk   )r,   ri   rx   r   rR   rR   rS   rx   >  s    zIntervalIndex.leftc                 C  s   t | jjddS r   )r,   ri   rt   r   rR   rR   rS   rt   B  s    zIntervalIndex.rightc                 C  s   t | jjddS r   )r,   ri   midr   rR   rR   rS   r   F  s    zIntervalIndex.midc                 C  s   t | jjddS r   )r,   ri   lengthr   rR   rR   rS   r   J  s    zIntervalIndex.lengthc                 C  sf   | j jr| jjr| |}n6|j jrH|jjrH|   dkrH|| }n
| |}|du rb| }|S )zL
        intersection specialized to the case with matching dtypes.
        rD   N)rx   r   rt   _intersection_uniquer   r   _intersection_non_uniqueZsort_values)r}   othersortZtakenrR   rR   rS   _intersectionQ  s     
zIntervalIndex._intersection)r   rm   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   )rx   r   rt   Ztaker   r'   )r}   r   ZlindexerZrindexermatchr   rR   rR   rS   r   e  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 rdd||< qd| | 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)rJ   Zzerosr   rh   r   r   r   r   ziprx   rt   r   )r}   r   r   Zfirst_nan_locZ
other_tupsr   tuprR   rR   rS   r   {  s    
z&IntervalIndex._intersection_non_uniquez
np.ndarrayc                 C  s   t dd S )NzRIntervalIndex does not use libjoin fastpaths or pass values to IndexEngine objectsr   r   rR   rR   rS   _get_engine_target  s    z IntervalIndex._get_engine_targetc                 C  s   t dd S )Nz,IntervalIndex does not use libjoin fastpathsr   )r}   resultrR   rR   rS   _from_join_target  s    zIntervalIndex._from_join_target)NNFNT)rt   NFN)rt   NFN)rt   NFN)F)rx   )NNN)9rn   
__module____qualname__Z_typ__annotations__Z_can_hold_stringsr)   Z	_data_clsrr   classmethodr   r*   textwrapdedentrs   rV   ry   r   r~   r   r   r   r   propertyr   r,   r   __doc__r   r   r   r   r|   r   r   r   r-   _index_doc_kwargsr   r   r   r   Z_requires_unique_msgr   r   r   r   rx   rt   r   r   r   r   r   r   r   __classcell__rR   rR   r   rS   r=      s   
-                 	
1BF    	rh   rz   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   rI   r   r   )endpointrR   rR   rS   _is_valid_endpoint  s    r   c                 C  sL   dd }dd }t | r t |pJ|| r0||pJ|| r@||pJt| |S )zK
    Helper for interval_range to check type compat of start/end/freq.
    c                 S  s   t | ttfS r   )rI   r   r   xrR   rR   rS   <lambda>      z%_is_type_compatible.<locals>.<lambda>c                 S  s   t | ttfS r   )rI   r   r   r   rR   rR   rS   r     r   )r   comany_none)abZis_ts_compatZis_td_compatrR   rR   rS   _is_type_compatible  s    
r   rt   rj   r:   )r@   rf   rm   c           	   
   C  s(  t | } t |}| dur| n|}|du rFt|| |rFt|rBdnd}t| |||dkrbtdt| sxtd|  t|std| t|}|durt|szt|}W n4 ty } ztd| |W Y d}~n
d}~0 0 t	t
| |t
| |t
||gstd	|dur$|d7 }t|rt| ||rVt| ||d
  |}nd|du rvt||  | d }n6| du r||d |  } n|du r| |d |  }t| ||}t	dd t| ||D rt|td}n.t|trt| |||d}nt| |||d}tj|||dS )a  
    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, Timedelta, datetime.timedelta, 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 00:00:00, 2017-01-02 00:00:00],
                   (2017-01-02 00:00:00, 2017-01-03 00:00:00],
                   (2017-01-03 00:00:00, 2017-01-04 00:00:00]],
                  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 00:00:00, 2017-02-01 00:00:00],
                   (2017-02-01 00:00:00, 2017-03-01 00:00:00],
                   (2017-03-01 00:00:00, 2017-04-01 00:00:00]],
                  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]')
    NrD   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 z7freq must be numeric or convertible to DateOffset, got z+start, end, freq need to be type compatibleg?c                 s  s   | ]}t |V  qd S r   )r   ).0r   rR   rR   rS   	<genexpr>_  r   z!interval_range.<locals>.<genexpr>Zint64)r   endperiodsfreq)r@   rf   )r   r   r   r   Zcount_not_noner   r   r(   r   allr   rN   Zall_not_nonerJ   r   r   ZlinspaceZnot_noner   rB   rI   r   r1   r6   r=   rs   )	r   r   r   r   r@   rf   r   r   rw   rR   rR   rS   interval_range  sf    `




r   )NNNNNrt   )hr   
__future__r   operatorr   r   r   typingr   r   r   numpyrJ   Zpandas._libsr   Zpandas._libs.intervalr	   r
   r   Zpandas._libs.tslibsr   r   r   r   r   Zpandas.errorsr   Zpandas.util._decoratorsr   r   Zpandas.util._exceptionsr   Zpandas.core.dtypes.castr   r   r   r   r   Zpandas.core.dtypes.commonr   r   r   r   r   r   r    r!   r"   Zpandas.core.dtypes.dtypesr#   r$   Zpandas.core.dtypes.missingr%   Zpandas.core.algorithmsr'   Zpandas.core.arrays.datetimeliker(   Zpandas.core.arrays.intervalr)   r*   Zpandas.core.commoncorecommonr   Zpandas.core.indexersr+   Zpandas.core.indexes.baseZindexesbaseZibaser,   r-   r.   r/   Zpandas.core.indexes.datetimesr0   r1   Zpandas.core.indexes.extensionr2   r3   Zpandas.core.indexes.multir4   Zpandas.core.indexes.timedeltasr5   r6   collections.abcr7   Zpandas._typingr8   r9   r:   r;   r<   dictr   updater   rT   rU   rY   r=   r   r   r   rR   rR   rR   rS   <module>   s   ,

     c      