@@ -182,23 +182,30 @@ def asi8(self) -> npt.NDArray[np.int64]:
182182 def freqstr (self ) -> str :
183183 """
184184 Return the frequency object as a string if it's set, otherwise None.
185+
185186 See Also
186187 --------
187188 DatetimeIndex.inferred_freq : Returns a string representing a frequency
188189 generated by infer_freq.
190+
189191 Examples
190192 --------
191193 For DatetimeIndex:
194+
192195 >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00"], freq="D")
193196 >>> idx.freqstr
194197 'D'
198+
195199 The frequency can be inferred if there are more than 2 points:
200+
196201 >>> idx = pd.DatetimeIndex(
197202 ... ["2018-01-01", "2018-01-03", "2018-01-05"], freq="infer"
198203 ... )
199204 >>> idx.freqstr
200205 '2D'
206+
201207 For PeriodIndex:
208+
202209 >>> idx = pd.PeriodIndex(["2023-1", "2023-2", "2023-3"], freq="M")
203210 >>> idx.freqstr
204211 'M'
@@ -269,22 +276,27 @@ def equals(self, other: Any) -> bool:
269276 def __contains__ (self , key : Any ) -> bool :
270277 """
271278 Return a boolean indicating whether the provided key is in the index.
279+
272280 Parameters
273281 ----------
274282 key : label
275283 The key to check if it is present in the index.
284+
276285 Returns
277286 -------
278287 bool
279288 Whether the key search is in the index.
289+
280290 Raises
281291 ------
282292 TypeError
283293 If the key is not hashable.
294+
284295 See Also
285296 --------
286297 Index.isin : Returns an ndarray of boolean dtype indicating whether the
287298 list-like key is in the index.
299+
288300 Examples
289301 --------
290302 >>> idx = pd.Index([1, 2, 3, 4])
@@ -340,10 +352,12 @@ def _format_attrs(self):
340352 def _summary (self , name = None ) -> str :
341353 """
342354 Return a summarized representation.
355+
343356 Parameters
344357 ----------
345358 name : str
346359 name to use in the summary representation
360+
347361 Returns
348362 -------
349363 String with a summarized representation of the index
@@ -607,6 +621,7 @@ def shift(self, periods: int = 1, freq=None) -> Self:
607621 Shift index by desired number of time frequency increments.
608622 This method is for shifting the values of datetime-like indexes
609623 by a specified time increment a given number of times.
624+
610625 Parameters
611626 ----------
612627 periods : int, default 1
@@ -616,10 +631,12 @@ def shift(self, periods: int = 1, freq=None) -> Self:
616631 Frequency increment to shift by.
617632 If None, the index is shifted by its own `freq` attribute.
618633 Offset aliases are valid strings, e.g., 'D', 'W', 'M' etc.
634+
619635 Returns
620636 -------
621637 pandas.DatetimeIndex
622638 Shifted index.
639+
623640 See Also
624641 --------
625642 Index.shift : Shift values of Index.
@@ -654,10 +671,12 @@ def inferred_freq(self) -> str | None:
654671 """
655672 Tries to return a string representing a frequency generated by infer_freq.
656673 Returns None if it can't autodetect the frequency.
674+
657675 See Also
658676 --------
659677 DatetimeIndex.freqstr : Return the frequency object as a string if it's set,
660678 otherwise None.
679+
661680 Examples
662681 --------
663682 For DatetimeIndex:
0 commit comments