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
U
¬ý°d¦&ã@sdZddlmZddlmZmZddlmZm    Z    m
Z
ddl m Z ddl mZmZmZddlmZddlmZdd    lmZdd
lmmZdd lmZmZdd lm Z dd l!m"Z"e"dddddddgej#edde"ddddddgeƒGdd„de ƒƒƒZ$d%d
dœd d!dd"œd#d$„Z%d
S)&z implement the TimedeltaIndex é)Ú annotations)ÚindexÚlib)Ú
ResolutionÚ    TimedeltaÚ    to_offset)ÚDtypeObj)Úis_dtype_equalÚ    is_scalarÚis_timedelta64_dtype)Ú    ABCSeries)Ú datetimelike)ÚTimedeltaArrayN)ÚIndexÚmaybe_extract_name)ÚDatetimeTimedeltaMixin)Ú inherit_namesÚ__neg__Ú__pos__Ú__abs__Ú total_secondsÚroundÚfloorÚceilT)ÚwrapÚ
componentsZto_pytimedeltaÚsumZstdZmedianZ_format_native_typesc@s²eZdZUdZdZeZeddœdd„ƒZde    d<e
j Z ed    dœd
d „ƒZ d d e jd d d d fddœdd„Zdddœdd„Zdd„Zddœdd„Zddœdd„Zeddœd d!„ƒZd S)"ÚTimedeltaIndexaŸ
    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.
    unit : unit of the arg (D,h,m,s,ms,us,ns) denote the unit, optional
        Which is an integer/float number.
    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.
    copy  : bool
        Make a copy of input ndarray.
    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 `this link
    <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases>`__.
    Ztimedeltaindexztype[libindex.TimedeltaEngine])ÚreturncCstjS©N)ÚlibindexZTimedeltaEngine©Úself©r#úUd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/indexes/timedeltas.pyÚ _engine_typelszTimedeltaIndex._engine_typerÚ_datazResolution | NonecCs|jjSr)r&Ú_resolution_objr!r#r#r$r'wszTimedeltaIndex._resolution_objNFÚbool)Úcopyc
Csôt|||ƒ}t|ƒr| |¡|dkr.tdƒ‚t|tƒrp|tjkrp|dksVt||j    ƒrp|rb| 
¡}|j ||dSt|t ƒr´|tjkr´|dkr´|dks t||j    ƒr´|r¬| 
¡S|  ¡Stj|||||d}d}    |sät|ttfƒrä|j}    |j |||    dS)N>ÚMÚYÚyzqUnits 'M', 'Y', and 'y' are no longer supported, as they do not represent unambiguous timedelta values durations.©Úname)ÚfreqÚunitÚdtyper))r.Úrefs)rr
Z_raise_scalar_data_errorÚ
ValueErrorÚ
isinstancerrÚ
no_defaultr    r1r)Ú _simple_newrZ_viewZ_from_sequence_not_strictr rZ _references)
ÚclsÚdatar0r/Úclosedr1r)r.Útdarrr2r#r#r$Ú__new__~sT
 
ÿÿþý
ýÿþýü
üÿzTimedeltaIndex.__new__r)r1rcCst|ƒS)zF
        Can we compare values of the given dtype to our own?
        )r )r"r1r#r#r$Ú_is_comparable_dtype´sz#TimedeltaIndex._is_comparable_dtypec
CsX| |¡z|jj|dd}Wn,tk
rJ}zt|ƒ|‚W5d}~XYnXt ||¡S)z…
        Get integer location for requested label
 
        Returns
        -------
        loc : int, slice, or ndarray[int]
        F)ZunboxN)Z_check_indexing_errorr&Z_validate_scalarÚ    TypeErrorÚKeyErrorrÚget_loc)r"ÚkeyÚerrr#r#r$r?½s 
zTimedeltaIndex.get_locÚstr)ÚlabelcCst|ƒ}|dfSr)r)r"rCÚparsedr#r#r$Ú_parse_with_resoÎszTimedeltaIndex._parse_with_resor)rDcCs,| |j¡}|t|jƒtddƒ}||fS)NéÚns)rZresolution_stringrr)r"ZresorDZlboundZrboundr#r#r$Ú_parsed_string_to_boundsÓs z'TimedeltaIndex._parsed_string_to_boundscCsdS)NZ timedelta64r#r!r#r#r$Ú inferred_typeÛszTimedeltaIndex.inferred_type)Ú__name__Ú
__module__Ú __qualname__Ú__doc__Z_typrZ    _data_clsÚpropertyr%Ú__annotations__rZ_get_string_slicer'rr5r;r<r?rErHrIr#r#r#r$r!s.
5ø6    r)r0z
int | Nonez
str | None)Úperiodsr0rc    CsL|dkrt |||¡rd}t |¡\}}tj||||||d}tj||dS)a3
    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 or DateOffset, default 'D'
        Frequency strings can have multiples, e.g. '5H'.
    name : str, 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 : str, default None
        Specify the desired resolution of the result.
 
        .. versionadded:: 2.0.0
 
    Returns
    -------
    TimedeltaIndex
 
    Notes
    -----
    Of the four parameters ``start``, ``end``, ``periods``, and ``freq``,
    exactly three must be specified. If ``freq`` is omitted, the resulting
    ``TimedeltaIndex`` will have ``periods`` linearly spaced elements between
    ``start`` and ``end`` (closed on both sides).
 
    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.timedelta_range(start='1 day', periods=4)
    TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'],
                   dtype='timedelta64[ns]', 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[ns]', 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[ns]', 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[ns]', freq=None)
 
    **Specify a unit**
 
    >>> pd.timedelta_range("1 Day", periods=3, freq="100000D", unit="s")
    TimedeltaIndex(['1 days 00:00:00', '100001 days 00:00:00',
                    '200001 days 00:00:00'],
                   dtype='timedelta64[s]', freq='100000D')
    NÚD)r9r0r-)ÚcomZany_noneÚdtlZmaybe_infer_freqrZ_generate_rangerr6)    ÚstartÚendrPr/r.r9r0Ú_r:r#r#r$Útimedelta_rangeàsTÿrW)NNNNNN)&rMÚ
__future__rZ pandas._libsrr rZpandas._libs.tslibsrrrZpandas._typingrZpandas.core.dtypes.commonr    r
r Zpandas.core.dtypes.genericr Zpandas.core.arraysr rSZpandas.core.arrays.timedeltasrZpandas.core.commonÚcoreÚcommonrRZpandas.core.indexes.baserrZ pandas.core.indexes.datetimelikerZpandas.core.indexes.extensionrZ
_field_opsrrWr#r#r#r$Ú<module>sP       ÿüú÷ 0úø