Skip to content

Commit 1ec3cdc

Browse files
authored
Update datetimelike.py
1 parent 3d9ad61 commit 1ec3cdc

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

pandas/core/indexes/datetimelike.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
NullFrequencyError,
3737
)
3838
from pandas.util._decorators import (
39+
Appender,
3940
cache_readonly,
41+
doc,
4042
)
4143

4244
from pandas.core.dtypes.common import (
@@ -55,10 +57,12 @@
5557
PeriodArray,
5658
TimedeltaArray,
5759
)
60+
from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin
5861
import pandas.core.common as com
5962
import pandas.core.indexes.base as ibase
6063
from pandas.core.indexes.base import (
6164
Index,
65+
_index_shared_docs,
6266
)
6367
from pandas.core.indexes.extension import NDArrayBackedExtensionIndex
6468
from pandas.core.indexes.range import RangeIndex
@@ -103,6 +107,21 @@ def mean(self, *, skipna: bool = True, axis: int | None = 0):
103107
-------
104108
scalar
105109
Timestamp or Timedelta.
110+
111+
See Also
112+
--------
113+
numpy.ndarray.mean : Returns the average of the array elements.
114+
Series.mean : Return the mean value in a Series.
115+
116+
Examples
117+
--------
118+
>>> idx = pd.date_range('2023-01-01', periods=3)
119+
>>> idx.mean()
120+
Timestamp('2023-01-02 00:00:00')
121+
122+
>>> idx = pd.to_timedelta([1, 2, 3], unit='D')
123+
>>> idx.mean()
124+
Timedelta('2 days 00:00:00')
106125
"""
107126
return self._data.mean(skipna=skipna, axis=axis)
108127

@@ -149,6 +168,18 @@ def asi8(self) -> npt.NDArray[np.int64]:
149168
def freqstr(self) -> str:
150169
"""
151170
Return the frequency string if it is set, otherwise None.
171+
172+
See Also
173+
--------
174+
DatetimeIndex.freq : Return the frequency object if it is set, otherwise None.
175+
DatetimeIndex.inferred_freq : Tries to return a string representing a frequency
176+
guess generated by infer_freq.
177+
178+
Examples
179+
--------
180+
>>> idx = pd.date_range('2023-01-01', periods=3, freq='D')
181+
>>> idx.freqstr
182+
'D'
152183
"""
153184
from pandas import PeriodIndex
154185

@@ -591,6 +622,17 @@ def inferred_freq(self) -> str | None:
591622
Returns
592623
-------
593624
str or None
625+
626+
See Also
627+
--------
628+
DatetimeIndex.freq : Return the frequency object if it is set, otherwise None.
629+
DatetimeIndex.freqstr : Return the frequency string if it is set, otherwise None.
630+
631+
Examples
632+
--------
633+
>>> idx = pd.DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05'])
634+
>>> idx.inferred_freq
635+
'2D'
594636
"""
595637
return self._data.inferred_freq
596638

0 commit comments

Comments
 (0)