Skip to content

Commit

Permalink
Fix doc errors for various datetime functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranav-Wadhwa committed Oct 11, 2024
1 parent 2b9ca07 commit 52ab1a8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,12 @@ def strftime(self, date_format: str) -> npt.NDArray[np.object_]:
----------
date_format : str
Date format string (e.g. "%%Y-%%m-%%d").
*args
Additional arguments and keywords have no effect but might be
accepted for compatibility with NumPy.
**kwargs
Additional arguments and keywords have no effect but might be
accepted for compatibility with NumPy.
Returns
-------
Expand Down Expand Up @@ -2066,6 +2072,24 @@ def _creso(self) -> int:

@cache_readonly
def unit(self) -> str:
"""
The precision of the datetime data.
Returns the most precise unit used for the datetime data.
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 = pd.DatetimeIndex(["2020-01-02 01:02:03"])
>>> idx.unit
's'
"""
# e.g. "ns", "us", "ms"
# error: Argument 1 to "dtype_to_unit" has incompatible type
# "ExtensionDtype"; expected "Union[DatetimeTZDtype, dtype[Any]]"
Expand Down
23 changes: 23 additions & 0 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,12 +858,23 @@ def tz_convert(self, tz) -> Self:
"""
Convert tz-aware Datetime Array/Index from one time zone to another.
This method is used to convert a timezone-aware Datetime Array or Index to
a different time zone. The original UTC time remains the same; only the
time zone information is changed. If the Timestamp is timezone-naive, a
TypeError is raised.
Parameters
----------
tz : str, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile, datetime.tzinfo or None
Time zone for time. Corresponding timestamps would be converted
to this time zone of the Datetime Array/Index. A `tz` of None will
convert to UTC and remove the timezone information.
*args
Additional arguments and keywords have no effect but might be
accepted for compatibility with NumPy.
**kwargs
Additional arguments and keywords have no effect but might be
accepted for compatibility with NumPy.
Returns
-------
Expand Down Expand Up @@ -985,6 +996,12 @@ def tz_localize(
- timedelta objects will shift nonexistent times by the timedelta
- 'raise' will raise a ValueError if there are
nonexistent times.
*args
Additional arguments and keywords have no effect but might be
accepted for compatibility with NumPy.
**kwargs
Additional arguments and keywords have no effect but might be
accepted for compatibility with NumPy.
Returns
-------
Expand Down Expand Up @@ -1204,6 +1221,12 @@ def to_period(self, freq=None) -> PeriodArray:
freq : str or Period, optional
One of pandas' :ref:`period aliases <timeseries.period_aliases>`
or an Period object. Will be inferred by default.
*args
Additional arguments and keywords have no effect but might be
accepted for compatibility with NumPy.
**kwargs
Additional arguments and keywords have no effect but might be
accepted for compatibility with NumPy.
Returns
-------
Expand Down
9 changes: 9 additions & 0 deletions pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,15 @@ def total_seconds(self) -> npt.NDArray[np.float64]:
This method is available directly on TimedeltaArray, TimedeltaIndex
and on Series containing timedelta values under the ``.dt`` namespace.
Parameters
----------
*args
Additional arguments and keywords have no effect but might be
accepted for compatibility with NumPy.
**kwargs
Additional arguments and keywords have no effect but might be
accepted for compatibility with NumPy.
Returns
-------
ndarray, Index or Series
Expand Down

0 comments on commit 52ab1a8

Please sign in to comment.