
    I j3              	         S r SSKJr  SSKJrJr  SSKJrJ	r	  SSK
JrJrJr  SSKJr  SSKJr  SSKJrJr  SS	KJr  SS
KJr  SSKJr  SSKJs  Jr  SSKJ r J!r!  SSK"J#r#  SSK$J%r%  \(       a  SSKJ&r&  SSK
J'r'J(r(  SSK)J*r*J+r+  \%" SSSSSSS/\RX                  Q\SS9\%" / SQ\5      \" S5       " S S\#5      5       5       5       r-\" S5            S"SS .     S#S! jjj5       r.g)$zimplement the TimedeltaIndex    )annotations)TYPE_CHECKINGcast)indexlib)
Resolution	Timedelta	to_offset)abbrev_to_npy_unit)
set_module)	is_scalarpandas_dtype)
ArrowDtype)	ABCSeries)TimedeltaArrayN)Indexmaybe_extract_name)DatetimeTimedeltaMixin)inherit_names)NaTType)DayTick)DtypeObjTimeUnit__neg____pos____abs__total_secondsroundfloorceilT)wrap)
componentsto_pytimedeltasumstdmedianpandasc                      \ rS rSr% SrSr\r\SS j5       r	S\
S'   \R                  r\SS j5       rS\R                  SSS4 SS	 jjrSS
 jrS rSS jrSS jr\SS j5       rSrg)TimedeltaIndex2   a0  
Immutable Index of timedelta64 data.

Represented internally as int64, and scalars returned Timedelta objects.

Parameters
----------
data : array-like (1-dimensional), optional
    Optional timedelta-like data to construct index with.
freq : str or pandas offset object, optional
    One of pandas date offset strings or corresponding objects. The string
    ``'infer'`` can be passed in order to set the frequency of the index as
    the inferred frequency upon creation.
dtype : numpy.dtype or str, default None
    Valid ``numpy`` dtypes are ``timedelta64[ns]``, ``timedelta64[us]``,
    ``timedelta64[ms]``, and ``timedelta64[s]``.
copy : bool, default None
    Whether to copy input data, only relevant for array, Series, and Index
    inputs (for other input, e.g. a list, a new array is created anyway).
    Defaults to True for array input and False for Index/Series.
    Set to False to avoid copying array input at your own risk (if you
    know the input data won't be modified elsewhere).
    Set to True to force copying Series/Index input up front.
name : object
    Name to be stored in the index.

Attributes
----------
days
seconds
microseconds
nanoseconds
components
inferred_freq

Methods
-------
to_pytimedelta
to_series
round
floor
ceil
to_frame
mean

See Also
--------
Index : The base pandas Index type.
Timedelta : Represents a duration between two dates or times.
DatetimeIndex : Index of datetime64 data.
PeriodIndex : Index of Period data.
timedelta_range : Create a fixed-frequency TimedeltaIndex.

Notes
-----
To learn more about the frequency strings, please see
:ref:`this link<timeseries.offset_aliases>`.

Examples
--------
>>> pd.TimedeltaIndex(["0 days", "1 days", "2 days", "3 days", "4 days"])
TimedeltaIndex(['0 days', '1 days', '2 days', '3 days', '4 days'],
               dtype='timedelta64[us]', freq=None)

We can also let pandas infer the frequency when possible.

>>> pd.TimedeltaIndex(np.arange(5) * 24 * 3600 * 1e9, freq="infer")
TimedeltaIndex(['0 days', '1 days', '2 days', '3 days', '4 days'],
               dtype='timedelta64[ns]', freq='D')
timedeltaindexc                "    [         R                  $ N)libindexTimedeltaEngineselfs    o/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/pandas/core/indexes/timedeltas.py_engine_typeTimedeltaIndex._engine_type   s    '''    r   _datac                .    U R                   R                  $ r.   )r7   _resolution_objr1   s    r3   r9   TimedeltaIndex._resolution_obj   s    zz)))r6   Nc                   [        XQU 5      nU R                  XU5      u  p[        U5      (       a  U R                  U5        Ub  [	        U5      n[        U[        5      (       aK  U[        R                  L a8  Ub  X1R                  :X  a&  U(       a  UR                  5       nU R                  XS9$ [        U[        5      (       aO  U[        R                  L a<  Uc9  Ub  X1R                  :X  a'  U(       a  UR                  5       $ UR                  5       $ [        R                  " XS X4S9nS nU(       d'  [        U[        [         45      (       a  UR"                  nU R                  XeUS9$ )Nname)frequnitdtypecopy)r=   refs)r   _maybe_copy_array_inputr   _raise_scalar_data_errorr   
isinstancer   r   
no_defaultr@   rA   _simple_newr*   _view_from_sequence_not_strictr   r   _references)clsdatar>   r@   rA   r=   tdarrrB   s           r3   __new__TimedeltaIndex.__new__   s0    "$c2 00UC
T??((. 'E t^,,&%::"5yy{??4?33 t^,,&%::"5yy{"zz|# 88$e
 
4)U);<<##Dud;;r6   c                x    [        U[        5      (       a  UR                  S:H  $ [        R                  " US5      $ )z6
Can we compare values of the given dtype to our own?
m)rE   r   kindr   is_np_dtype)r2   r@   s     r3   _is_comparable_dtype#TimedeltaIndex._is_comparable_dtype   s1     eZ((::$$uc**r6   c                    U R                  U5         U R                  R                  USS9n[
        R                  " X5      $ ! [         a  n[	        U5      UeSnAff = f)z]
Get integer location for requested label

Returns
-------
loc : int, slice, or ndarray[int]
F)unboxN)_check_indexing_errorr7   _validate_scalar	TypeErrorKeyErrorr   get_loc)r2   keyerrs      r3   r\   TimedeltaIndex.get_loc   s_     	""3'	)**--c-?C }}T''  	)3-S(	)s   A 
AAAc                    [        U5      n[        U[         5      (       a#  [        R                  " UR                  5      nX#4$ [        R                  " S5      nX#4$ )Ns)r	   rE   r   get_reso_from_freqstrr?   )r2   labelparsedresos       r3   _parse_with_resoTimedeltaIndex._parse_with_reso   sQ    5!fi((33FKK@D | 33C8D|r6   c                    UR                  UR                  5      nU[        UR                  5      -   [        SU R                  S9R                  U R                  5      -
  nX44$ )N   r?   )r   resolution_stringr
   r	   r?   as_unit)r2   re   rd   lboundrbounds        r3   _parsed_string_to_bounds'TimedeltaIndex._parsed_string_to_bounds  s]    f6670012		*22499=> 	
 ~r6   c                    g)Ntimedelta64 r1   s    r3   inferred_typeTimedeltaIndex.inferred_type  s    r6   rs   )returnztype[libindex.TimedeltaEngine])rv   zResolution | None)rA   zbool | None)r@   r   rv   bool)rc   strrv   z&tuple[Timedelta | NaTType, Resolution])re   r   rd   r	   )rv   rx   )__name__
__module____qualname____firstlineno____doc___typr   	_data_clspropertyr4   __annotations__r   _get_string_slicer9   r   rF   rN   rT   r\   rf   ro   rt   __static_attributes__rs   r6   r3   r*   r*   2   s    4EN DI( (  // * * ^^ 0<
 0<h+(*  r6   r*   rj   c          	        Uc  [         R                  " X U5      (       a  Sn[        U5      n[         R                  " XX#5      S:w  a  [	        S5      eUGcF  U b  Ub  [        U 5      n [        U5      n[        [
        U 5      n [        [
        U5      n[        U R                  5      [        UR                  5      :  a  [        SU R                  5      nO}[        SUR                  5      nOfU b2  [        U 5      n [        [
        U 5      n [        SU R                  5      nO1[        U5      n[        [
        U5      n[        SUR                  5      nUbG  [        SU5      n[        U5      nUR                  U:  a   [        SUR                  R                  5      n[        R                  " XX#XVS9n[        R                  XS9$ )a  
Return a fixed frequency TimedeltaIndex with day as the default.

Parameters
----------
start : str or timedelta-like, default None
    Left bound for generating timedeltas.
end : str or timedelta-like, default None
    Right bound for generating timedeltas.
periods : int, default None
    Number of periods to generate.
freq : str, Timedelta, datetime.timedelta, or DateOffset, default 'D'
    Frequency strings can have multiples, e.g. '5h'.
name : Hashable, default None
    Name of the resulting TimedeltaIndex.
closed : str, default None
    Make the interval closed with respect to the given frequency to
    the 'left', 'right', or both sides (None).
unit : {'s', 'ms', 'us', 'ns', None}, default None
    Specify the desired resolution of the result.
    If not specified, this is inferred from the 'start', 'end', and 'freq'
    using the same inference as :class:`Timedelta` taking the highest
    resolution of the three that are provided.

    .. versionadded:: 2.0.0

Returns
-------
TimedeltaIndex
    Fixed frequency, with day as the default.

See Also
--------
date_range : Return a fixed frequency DatetimeIndex.
period_range : Return a fixed frequency PeriodIndex.

Notes
-----
Of the four parameters ``start``, ``end``, ``periods``, and ``freq``,
a maximum of three can be specified at once. Of the three parameters
``start``, ``end``, and ``periods``, at least two must be specified.
If ``freq`` is omitted, the resulting ``DatetimeIndex`` will have
``periods`` linearly spaced elements between ``start`` and ``end``
(closed on both sides).

To learn more about the frequency strings, please see
:ref:`this link<timeseries.offset_aliases>`.

Examples
--------
>>> pd.timedelta_range(start="1 day", periods=4)
TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'],
               dtype='timedelta64[us]', freq='D')

The ``closed`` parameter specifies which endpoint is included.  The default
behavior is to include both endpoints.

>>> pd.timedelta_range(start="1 day", periods=4, closed="right")
TimedeltaIndex(['2 days', '3 days', '4 days'],
               dtype='timedelta64[us]', freq='D')

The ``freq`` parameter specifies the frequency of the TimedeltaIndex.
Only fixed frequencies can be passed, non-fixed frequencies such as
'M' (month end) will raise.

>>> pd.timedelta_range(start="1 day", end="2 days", freq="6h")
TimedeltaIndex(['1 days 00:00:00', '1 days 06:00:00', '1 days 12:00:00',
                '1 days 18:00:00', '2 days 00:00:00'],
               dtype='timedelta64[us]', freq='6h')

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

>>> pd.timedelta_range(start="1 day", end="5 days", periods=4)
TimedeltaIndex(['1 days 00:00:00', '2 days 08:00:00', '3 days 16:00:00',
                '5 days 00:00:00'],
               dtype='timedelta64[us]', freq=None)

**Specify a unit**

>>> pd.timedelta_range("1 Day", periods=3, freq="100000D", unit="s")
TimedeltaIndex(['1 days', '100001 days', '200001 days'],
               dtype='timedelta64[s]', freq='100000D')
D   zVOf the four parameters: start, end, periods, and freq, exactly three must be specifiedr   z
Tick | Day)closedr?   r<   )comany_noner
   count_not_none
ValueErrorr	   r   r   r?   _cresobasefreqstrr   _generate_ranger*   rG   )	startendperiodsr>   r=   r   r?   cresorM   s	            r3   timedelta_ranger     s   ~ |WS99T?D
%g498
 	

 | e$EC.CE*Ey#&C!%**-0B3880LLJ

3J1e$EE*E
EJJ/DC.Cy#&C
CHH-D d+D&t,E{{U"J		(9(9:**G&E %%e%77r6   )NNNNNN)r   z
int | Noner?   zTimeUnit | Nonerv   r*   )/r}   
__future__r   typingr   r   pandas._libsr   r/   r   pandas._libs.tslibsr   r	   r
   pandas._libs.tslibs.dtypesr   pandas.util._decoratorsr   pandas.core.dtypes.commonr   r   pandas.core.dtypes.dtypesr   pandas.core.dtypes.genericr   pandas.core.arrays.timedeltasr   pandas.core.commoncorecommonr   pandas.core.indexes.baser   r    pandas.core.indexes.datetimeliker   pandas.core.indexes.extensionr   r   r   r   pandas._typingr   r   
_field_opsr*   r   rs   r6   r3   <module>r      s3   " "
 
 : . 1 0 8     D 7$ 	 
	"	"	 	  	 HI+ I 	2IX H
		I8 !I8 I8 I8 I8 I8r6   