
    `VgaK                       d dl mZ d dlmZmZ d dlmZ d dlZd dlZd dl	m
ZmZ d dlmZmZmZmZmZ d dlmZmZmZ d dlmZmZ d d	lmZ d d
lmZmZmZ d dl m!Z! d dl"m#Z# d dl$m%Z%m&Z&m'Z'm(Z( d dl)m*c m+Z, d dl-m*c m.c m/Z0 d dl-m1Z1 d dl2m3Z3 d dl4m5Z5m6Z6 d dl7m8Z8 d dl9m:Z:  e;e0jx                        Z<e<j{                  ddi       ddiZ>d Z? e8g de%j                  z   e%d       e8ddge%       G d de3                    ZA	 d 	 	 	 d!dZBy)"    )annotations)datetime	timedelta)HashableN)indexlib)
BaseOffsetNaTPeriod
ResolutionTick)DtypeDtypeObjnpt)cache_readonlydoc)find_stack_level)is_datetime64_any_dtype
is_integerpandas_dtype)PeriodDtype)is_valid_na_for_dtype)PeriodArrayperiod_arrayraise_on_incompatiblevalidate_dtype_freq)maybe_extract_name)DatetimeIndexOpsMixin)DatetimeIndexIndex)inherit_names)
Int64Indextarget_klasszPeriodIndex or list of Periodsklassr   c                    |j                  d      }|j                  dk(  r2|j                  dd       }t        ||      } | j                  |fi |S  | |fi |S )Ndataint64freqr(   )popdtyper   _simple_new)clsdvaluesr(   s       [/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/pandas/core/indexes/period.py_new_PeriodIndexr1   D   s]    UU6]F||wuuVT"V$/sv+++6Q    )strftime
start_timeend_timeT)wrapis_leap_year_format_native_typesc                      e Zd ZU dZdZded<   ded<   ded<   eZd	Ze	d!d
       Z
ed"d       Z eej                  fddded#d$d       Z eej                         d%d&d       Ze	 eej"                  j$                        d'd              Ze	 eej&                  j$                        d'd              Ze	 eej(                  j$                        d'd              Z	 	 	 	 	 	 d(	 	 	 	 	 	 	 d)dZe	d*d       Zd+dZd,dZd- fdZ eej6                        d	ej:                  fd. fd       Ze	d/d       Ze	d0d       Z fdZ d1dZ!d2dZ"d Z# ee$jJ                        ej:                  fd3 fd       Z%d4d Z& xZ'S )5PeriodIndexa  
    Immutable ndarray holding ordinal values indicating regular periods in time.

    Index keys are boxed to Period objects which carries the metadata (eg,
    frequency information).

    Parameters
    ----------
    data : array-like (1d int np.ndarray or PeriodArray), optional
        Optional period-like data to construct index with.
    copy : bool
        Make a copy of input ndarray.
    freq : str or period object, optional
        One of pandas period strings or corresponding objects.
    year : int, array, or Series, default None
    month : int, array, or Series, default None
    quarter : int, array, or Series, default None
    day : int, array, or Series, default None
    hour : int, array, or Series, default None
    minute : int, array, or Series, default None
    second : int, array, or Series, default None
    dtype : str or PeriodDtype, default None

    Attributes
    ----------
    day
    dayofweek
    day_of_week
    dayofyear
    day_of_year
    days_in_month
    daysinmonth
    end_time
    freq
    freqstr
    hour
    is_leap_year
    minute
    month
    quarter
    qyear
    second
    start_time
    week
    weekday
    weekofyear
    year

    Methods
    -------
    asfreq
    strftime
    to_timestamp

    See Also
    --------
    Index : The base pandas Index type.
    Period : Represents a period of time.
    DatetimeIndex : Index with datetime64 data.
    TimedeltaIndex : Index of timedelta64 data.
    period_range : Create a fixed-frequency PeriodIndex.

    Examples
    --------
    >>> idx = pd.PeriodIndex(year=[2000, 2002], quarter=[1, 3])
    >>> idx
    PeriodIndex(['2000Q1', '2002Q3'], dtype='period[Q-DEC]')
    periodindexr   _datar	   r(   r   r+   Tc                "    t         j                  S N)libindexPeriodEngineselfs    r0   _engine_typezPeriodIndex._engine_type   s    $$$r2   c                .    | j                   j                  S r>   )r+   _resolution_objrA   s    r0   rE   zPeriodIndex._resolution_obj   s     zz)))r2   zpandas.arrays.PeriodArray)other
other_namec                    | j                   j                  ||      }t        |       j                  || j                        S Nname)r<   asfreqtyper,   rK   rB   r(   howarrs       r0   rL   zPeriodIndex.asfreq   s8     jjc*Dz%%c		%::r2   c                |    | j                   j                  ||      }t        j                  || j                        S rI   )r<   to_timestampr   r,   rK   rN   s       r0   rR   zPeriodIndex.to_timestamp   s/    jj%%dC0((499==r2   c                X    t        | j                  j                  | j                        S rI   )r"   r<   hourrK   rA   s    r0   rT   zPeriodIndex.hour   s     $**//		::r2   c                X    t        | j                  j                  | j                        S rI   )r"   r<   minuterK   rA   s    r0   rV   zPeriodIndex.minute        $**++$))<<r2   c                X    t        | j                  j                  | j                        S rI   )r"   r<   secondrK   rA   s    r0   rY   zPeriodIndex.second   rW   r2   c                t   h d}t        |      j                  |      s(t        t        |      |z
        d   }	t        d|	       t	        |||       }|A|?|s| j                  d       t        j                  d d d ||      \  }}
|
}t        ||      }n~t        ||      }|r,t        ||       r |j                  |k7  r|j                  |      }|5|3t        j                  |t        j                        }t        ||      }nt        ||      }|r|j!                         }| j#                  ||      S )N>   dayrT   yearmonthrV   rY   quarterr   z-__new__() got an unexpected keyword argument r)   r+   )r&   r(   rJ   )setissubsetlist	TypeErrorr   _scalar_data_errorr   _generate_ranger   
isinstancer(   rL   npasarrayr'   r   copyr,   )r-   r&   ordinalr(   r+   ri   rK   fieldsvalid_field_setargumentfreq2s              r0   __new__zPeriodIndex.__new__   s0   
 6{##O4CK/9:1=HKH:VWW!$c2<GO,,T22%55dD$fUKD% Dt$/D&ud3D
 
4-$))t2C {{4(| 3**WBHH="76 $D999;Dt$//r2   c                8    t        j                  | t              S )Nr_   )rg   rh   objectrA   s    r0   r/   zPeriodIndex.values  s    zz$f--r2   c                   t        |t        t        j                  t        t        j
                  f      r7t        | j                  t              ru| j                  j                  |      }|S t        |t              r;|j                  | j                  j                  k(  r|j                  S t        | |      t        |      r|S t        | d      )a  
        Convert timedelta-like input to an integer multiple of self.freq

        Parameters
        ----------
        other : timedelta, np.timedelta64, DateOffset, int, np.ndarray

        Returns
        -------
        converted : int, np.ndarray[int64]

        Raises
        ------
        IncompatibleFrequency : if the input cannot be written as a multiple
            of self.freq.  Note IncompatibleFrequency subclasses ValueError.
        N)rf   r   rg   timedelta64r   ndarrayr(   r<    _check_timedeltalike_freq_compatr	   basenr   r   )rB   rF   deltas      r0   _maybe_convert_timedeltaz$PeriodIndex._maybe_convert_timedelta  s    " eirzzJK$))T*

CCEJz*zzTYY^^+ww'e44 L $D$//r2   c                    t        |t              sy|j                  }| j                  }|j                  |j                  k(  xr |j                  |j                  k(  S )zF
        Can we compare values of the given dtype to our own?
        F)rf   r   r(   _period_dtype_coderw   )rB   r+   r(   own_freqs       r0   _is_comparable_dtypez PeriodIndex._is_comparable_dtypeC  sX     %-
 zz99##**+ % (**$		
r2   c                    t        |t              r"t        |j                  | j                        }nt        |t              st        d      t        |   ||      S )z
        where : array of timestamps
        mask : np.ndarray[bool]
            Array of booleans where data is not NA.
        r)   z6asof_locs `where` must be DatetimeIndex or PeriodIndex)rf   r   r:   _valuesr(   rc   super	asof_locs)rB   wheremask	__class__s      r0   r   zPeriodIndex.asof_locsY  sK     e]+DII>EE;/TUUw --r2   c                    t        |      }|t        j                  ur%t        j                  dt
        t                      nd}t        |      r.t        |dd       }| j                  |      j                  |      S t        | 1  ||      S )NzThe 'how' keyword in PeriodIndex.astype is deprecated and will be removed in a future version. Use index.to_timestamp(how=how) instead.)
stacklevelstarttzrO   )ri   )r   r   
no_defaultwarningswarnFutureWarningr   r   getattrrR   tz_localizer   astype)rB   r+   ri   rO   r   r   s        r0   r   zPeriodIndex.astypef  s    U#cnn$MM; +- C"5)
 d+B$$$-99"==w~e$~//r2   c                    t        |       dk(  ry| j                  st        d      | j                  }|dd |dd z
  dk  j	                         S )z
        Returns True if this PeriodIndex is range-like in that all Periods
        between start and end are present, in order.
        r   TzIndex is not monotonic   N   )lenis_monotonic_increasing
ValueErrorasi8all)rB   r/   s     r0   is_fullzPeriodIndex.is_full  sU     t9>++566fSbk)Q.3355r2   c                     y)Nperiod rA   s    r0   inferred_typezPeriodIndex.inferred_type  s     r2   c                |    t         |   ||      }| j                  |j                  k(  r| j                  |      }|S r>   )r   _convert_tolerancer+   ry   )rB   	tolerancetargetr   s      r0   r   zPeriodIndex._convert_tolerance  s<    
 G.y&A	::%55i@Ir2   c                $   |}| j                  |       t        || j                        rt        }nt	        |t
              r	 | j                  |      \  }}| j                  |      r	 | j                  ||      S || j                  k(  r'| j                  |      }| j                  |||      }|S |t        |      | j                  |      }nOt	        |t              r| j                  |      }n-t	        |t               r| j                  |      }nt        |      	 t#        j                  | |||      S # t        $ r}t        d| d      |d}~ww xY w# t        $ r}t        |      |d}~ww xY w# t        $ r}t        |      |d}~ww xY w)a  
        Get integer location for requested label.

        Parameters
        ----------
        key : Period, NaT, str, or datetime
            String or datetime key must be parsable as Period.

        Returns
        -------
        loc : int or ndarray[int64]

        Raises
        ------
        KeyError
            Key is not present in the index.
        TypeError
            If key is listlike or otherwise not hashable.
        zCannot interpret 'z' as periodN)methodr   )_check_indexing_errorr   r+   r
   rf   str_parse_with_resor   KeyError_can_partial_date_slice_partial_date_slicerE   _cast_partial_indexing_scalarget_locr   _maybe_cast_for_get_locr   r    )	rB   keyr   r   orig_keyparsedresoerrlocs	            r0   r   zPeriodIndex.get_loc  s   ( ""3' djj1CS!O#44S9
 ++D1133D&AA
 t+++ 88=ll3vlK 
sm#88@V$..s3CX&44S9C 3-	.==sFI>>G  O!3C5DE3NO   1"3-S01:  	.8$#-	.sH   D7 (E E5 7	E EE	E2!E--E25	F>F

Fc                    | j                   }|j                   }|j                  |j                  k(  r|j                  |j                  k(  st        |      |S r>   )r(   rw   r{   r   )rB   r   sfreqkfreqs       r0   r   z#PeriodIndex._maybe_cast_for_get_loc  sL    		GGuww((''( 3-
r2   c                p    	 t        || j                        }|S # t        $ r}t        |      |d }~ww xY w)Nr)   )r   r(   r   r   )rB   labelr   r   s       r0   r   z)PeriodIndex._cast_partial_indexing_scalar  s<    	+TYY/C 
  	+5/s*	+s    	505c                j    t        |t              r| j                  |      }t        |   |||      S )N)kind)rf   r   r   r   _maybe_cast_slice_bound)rB   r   sider   r   s       r0   r   z#PeriodIndex._maybe_cast_slice_bound  s4    eX&66u=Ew.ud.FFr2   c                    t        ||j                        }|j                  | j                  d      |j                  | j                  d      fS )Nr)   r   r   end)r   attr_abbrevrL   r(   )rB   r   r   ivs       r0   _parsed_string_to_boundsz$PeriodIndex._parsed_string_to_bounds	  sA    F!1!12		$))	1299TYYE93RSSr2   )returnztype[libindex.PeriodEngine])r   r   )NE)rO   r   r   r:   )Nr   )rO   r   r   r   )r   r"   )NNNNFN)r+   zDtype | Noneri   boolrK   r   r   r:   )r   
np.ndarray)r   zint | npt.NDArray[np.int64])r+   r   r   r   )r   r    r   znpt.NDArray[np.bool_]r   r   )ri   r   )r   r   )r   r   )NN)r   r   r   r   )r   r   )r   r   r   r   )(__name__
__module____qualname____doc___typ__annotations__r   	_data_cls!_supports_partial_string_indexingpropertyrC   r   rE   r   rL   _shared_doc_kwargsrR   rT   fgetrV   rY   ro   r/   ry   r}   r   r    r   r   r   r   r   r   r   r   r   r   r   r   __classcell__)r   s   @r0   r:   r:   O   s*   CJ D
I(,%% % * * 	)  	;; 		!	!"> #> 				;   ;
 			 	 != " =
 			 	 != " = "=0
 =0 =0 =0 
=0D . ."0H
,. 	)-3>> 0 02 
6 
6  D.L" 			6	67=@^^ G 8GTr2   r:   c                   t        j                  | ||      dk7  rt        d      |"t        | t              st        |t              sd}t        j                  | |||i       \  }}t        ||      }t        ||      S )a  
    Return a fixed frequency PeriodIndex.

    The day (calendar) is the default frequency.

    Parameters
    ----------
    start : str or period-like, default None
        Left bound for generating periods.
    end : str or period-like, default None
        Right bound for generating periods.
    periods : int, default None
        Number of periods to generate.
    freq : str or DateOffset, optional
        Frequency alias. By default the freq is taken from `start` or `end`
        if those are Period objects. Otherwise, the default is ``"D"`` for
        daily frequency.
    name : str, default None
        Name of the resulting PeriodIndex.

    Returns
    -------
    PeriodIndex

    Notes
    -----
    Of the three parameters: ``start``, ``end``, and ``periods``, exactly two
    must be specified.

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

    Examples
    --------
    >>> pd.period_range(start='2017-01-01', end='2018-01-01', freq='M')
    PeriodIndex(['2017-01', '2017-02', '2017-03', '2017-04', '2017-05', '2017-06',
             '2017-07', '2017-08', '2017-09', '2017-10', '2017-11', '2017-12',
             '2018-01'],
            dtype='period[M]')

    If ``start`` or ``end`` are ``Period`` objects, they will be used as anchor
    endpoints for a ``PeriodIndex`` with frequency matching that of the
    ``period_range`` constructor.

    >>> pd.period_range(start=pd.Period('2017Q1', freq='Q'),
    ...                 end=pd.Period('2017Q2', freq='Q'), freq='M')
    PeriodIndex(['2017-03', '2017-04', '2017-05', '2017-06'],
                dtype='period[M]')
    r   zOOf the three parameters: start, end, and periods, exactly two must be specifiedD)rk   r)   rJ   )comcount_not_noner   rf   r   r   re   r:   )r   r   periodsr(   rK   r&   s         r0   period_ranger     s    h %g.!3,
 	
 |Zv6z#v?V,,UC$rRJD$t$'Dt$''r2   )NNNNN)r   z
int | Noner   r:   )C
__future__r   r   r   typingr   r   numpyrg   pandas._libsr   r?   r   pandas._libs.tslibsr	   r
   r   r   r   pandas._typingr   r   r   pandas.util._decoratorsr   r   pandas.util._exceptionsr   pandas.core.dtypes.commonr   r   r   pandas.core.dtypes.dtypesr   pandas.core.dtypes.missingr   pandas.core.arrays.periodr   r   r   r   pandas.core.commoncorecommonr   pandas.core.indexes.baseindexesrv   ibaser    pandas.core.indexes.datetimeliker   pandas.core.indexes.datetimesr   r    pandas.core.indexes.extensionr!   pandas.core.indexes.numericr"   dict_index_doc_kwargsupdater   r1   
_field_opsr:   r   r   r2   r0   <module>r      s   "     
 5 
 2 <  !   ( ( 7 B 8 2001    .*JK L]   *[-C-CC	
  67EvT' vT FvTt GK>(#->(>(r2   