Skip to content

Commit

Permalink
DOC: Fix some docstring validations in pd.Series (#60481)
Browse files Browse the repository at this point in the history
* DOC: Fix some docstring validations in pd.Series

* new circle
  • Loading branch information
OscarGB authored Dec 3, 2024
1 parent 8695401 commit aa4b621
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 0 additions & 2 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Period.freq GL08" \
-i "pandas.Period.ordinal GL08" \
-i "pandas.RangeIndex.from_range PR01,SA01" \
-i "pandas.Series.dt.unit GL08" \
-i "pandas.Series.pad PR01,SA01" \
-i "pandas.Timedelta.max PR02" \
-i "pandas.Timedelta.min PR02" \
-i "pandas.Timedelta.resolution PR02" \
Expand Down
24 changes: 23 additions & 1 deletion pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,29 @@ def _creso(self) -> int:

@cache_readonly
def unit(self) -> str:
# e.g. "ns", "us", "ms"
"""
The precision unit of the datetime data.
Returns the precision unit for the dtype.
It means the smallest time frame that can be stored within this dtype.
Returns
-------
str
Unit string representation (e.g. "ns").
See Also
--------
TimelikeOps.as_unit : Converts to a specific unit.
Examples
--------
>>> idx = pd.DatetimeIndex(["2020-01-02 01:02:03.004005006"])
>>> idx.unit
'ns'
>>> idx.as_unit("s").unit
's'
"""
# error: Argument 1 to "dtype_to_unit" has incompatible type
# "ExtensionDtype"; expected "Union[DatetimeTZDtype, dtype[Any]]"
return dtype_to_unit(self.dtype) # type: ignore[arg-type]
Expand Down

0 comments on commit aa4b621

Please sign in to comment.