Skip to content

Commit aa4b621

Browse files
authored
DOC: Fix some docstring validations in pd.Series (#60481)
* DOC: Fix some docstring validations in pd.Series * new circle
1 parent 8695401 commit aa4b621

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

ci/code_checks.sh

-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7373
-i "pandas.Period.freq GL08" \
7474
-i "pandas.Period.ordinal GL08" \
7575
-i "pandas.RangeIndex.from_range PR01,SA01" \
76-
-i "pandas.Series.dt.unit GL08" \
77-
-i "pandas.Series.pad PR01,SA01" \
7876
-i "pandas.Timedelta.max PR02" \
7977
-i "pandas.Timedelta.min PR02" \
8078
-i "pandas.Timedelta.resolution PR02" \

pandas/core/arrays/datetimelike.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -2073,7 +2073,29 @@ def _creso(self) -> int:
20732073

20742074
@cache_readonly
20752075
def unit(self) -> str:
2076-
# e.g. "ns", "us", "ms"
2076+
"""
2077+
The precision unit of the datetime data.
2078+
2079+
Returns the precision unit for the dtype.
2080+
It means the smallest time frame that can be stored within this dtype.
2081+
2082+
Returns
2083+
-------
2084+
str
2085+
Unit string representation (e.g. "ns").
2086+
2087+
See Also
2088+
--------
2089+
TimelikeOps.as_unit : Converts to a specific unit.
2090+
2091+
Examples
2092+
--------
2093+
>>> idx = pd.DatetimeIndex(["2020-01-02 01:02:03.004005006"])
2094+
>>> idx.unit
2095+
'ns'
2096+
>>> idx.as_unit("s").unit
2097+
's'
2098+
"""
20772099
# error: Argument 1 to "dtype_to_unit" has incompatible type
20782100
# "ExtensionDtype"; expected "Union[DatetimeTZDtype, dtype[Any]]"
20792101
return dtype_to_unit(self.dtype) # type: ignore[arg-type]

0 commit comments

Comments
 (0)