diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 567ae6da92ae2..ae452a8c07ac8 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -86,14 +86,11 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then MSG='Partially validate docstrings (EX01)' ; echo $MSG $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \ pandas.Series.index \ - pandas.Series.dtype \ pandas.Series.nbytes \ pandas.Series.ndim \ pandas.Series.size \ pandas.Series.T \ pandas.Series.hasnans \ - pandas.Series.dtypes \ - pandas.Series.to_period \ pandas.Series.to_timestamp \ pandas.Series.to_list \ pandas.Series.__iter__ \ diff --git a/pandas/core/series.py b/pandas/core/series.py index 7af68a118889e..e4c7c4d3b3d73 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -580,6 +580,12 @@ def _can_hold_na(self) -> bool: def dtype(self) -> DtypeObj: """ Return the dtype object of the underlying data. + + Examples + -------- + >>> s = pd.Series([1, 2, 3]) + >>> s.dtype + dtype('int64') """ return self._mgr.dtype @@ -587,6 +593,12 @@ def dtype(self) -> DtypeObj: def dtypes(self) -> DtypeObj: """ Return the dtype object of the underlying data. + + Examples + -------- + >>> s = pd.Series([1, 2, 3]) + >>> s.dtypes + dtype('int64') """ # DataFrame compatibility return self.dtype @@ -5722,6 +5734,22 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series ------- Series Series with index converted to PeriodIndex. + + Examples + -------- + >>> idx = pd.DatetimeIndex(['2023', '2024', '2025']) + >>> s = pd.Series([1, 2, 3], index=idx) + >>> s = s.to_period() + >>> s + 2023 1 + 2024 2 + 2025 3 + Freq: A-DEC, dtype: int64 + + Viewing the index + + >>> s.index + PeriodIndex(['2023', '2024', '2025'], dtype='period[A-DEC]') """ if not isinstance(self.index, DatetimeIndex): raise TypeError(f"unsupported Type {type(self.index).__name__}")