Skip to content

DOC: Fix EX01 issues in docstrings #51387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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__ \
Expand Down
28 changes: 28 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,25 @@ 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

@property
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
Expand Down Expand Up @@ -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__}")
Expand Down