Skip to content

Commit 6db4c47

Browse files
authored
DOC: Fix EX01 issues in docstrings (#51387)
* DOC Fix EX01 issues in docstrings * DOC Fix EX01 errors in docstrings
1 parent 0788266 commit 6db4c47

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

ci/code_checks.sh

-3
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,11 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8686
MSG='Partially validate docstrings (EX01)' ; echo $MSG
8787
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \
8888
pandas.Series.index \
89-
pandas.Series.dtype \
9089
pandas.Series.nbytes \
9190
pandas.Series.ndim \
9291
pandas.Series.size \
9392
pandas.Series.T \
9493
pandas.Series.hasnans \
95-
pandas.Series.dtypes \
96-
pandas.Series.to_period \
9794
pandas.Series.to_timestamp \
9895
pandas.Series.to_list \
9996
pandas.Series.__iter__ \

pandas/core/series.py

+28
Original file line numberDiff line numberDiff line change
@@ -580,13 +580,25 @@ def _can_hold_na(self) -> bool:
580580
def dtype(self) -> DtypeObj:
581581
"""
582582
Return the dtype object of the underlying data.
583+
584+
Examples
585+
--------
586+
>>> s = pd.Series([1, 2, 3])
587+
>>> s.dtype
588+
dtype('int64')
583589
"""
584590
return self._mgr.dtype
585591

586592
@property
587593
def dtypes(self) -> DtypeObj:
588594
"""
589595
Return the dtype object of the underlying data.
596+
597+
Examples
598+
--------
599+
>>> s = pd.Series([1, 2, 3])
600+
>>> s.dtypes
601+
dtype('int64')
590602
"""
591603
# DataFrame compatibility
592604
return self.dtype
@@ -5722,6 +5734,22 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series
57225734
-------
57235735
Series
57245736
Series with index converted to PeriodIndex.
5737+
5738+
Examples
5739+
--------
5740+
>>> idx = pd.DatetimeIndex(['2023', '2024', '2025'])
5741+
>>> s = pd.Series([1, 2, 3], index=idx)
5742+
>>> s = s.to_period()
5743+
>>> s
5744+
2023 1
5745+
2024 2
5746+
2025 3
5747+
Freq: A-DEC, dtype: int64
5748+
5749+
Viewing the index
5750+
5751+
>>> s.index
5752+
PeriodIndex(['2023', '2024', '2025'], dtype='period[A-DEC]')
57255753
"""
57265754
if not isinstance(self.index, DatetimeIndex):
57275755
raise TypeError(f"unsupported Type {type(self.index).__name__}")

0 commit comments

Comments
 (0)