Skip to content

Commit 52ab1a8

Browse files
committed
Fix doc errors for various datetime functions
1 parent 2b9ca07 commit 52ab1a8

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

pandas/core/arrays/datetimelike.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,12 @@ def strftime(self, date_format: str) -> npt.NDArray[np.object_]:
17421742
----------
17431743
date_format : str
17441744
Date format string (e.g. "%%Y-%%m-%%d").
1745+
*args
1746+
Additional arguments and keywords have no effect but might be
1747+
accepted for compatibility with NumPy.
1748+
**kwargs
1749+
Additional arguments and keywords have no effect but might be
1750+
accepted for compatibility with NumPy.
17451751
17461752
Returns
17471753
-------
@@ -2066,6 +2072,24 @@ def _creso(self) -> int:
20662072

20672073
@cache_readonly
20682074
def unit(self) -> str:
2075+
"""
2076+
The precision of the datetime data.
2077+
2078+
Returns the most precise unit used for the datetime data.
2079+
2080+
See Also
2081+
--------
2082+
TimelikeOps.as_unit : Converts to a specific unit.
2083+
2084+
Examples
2085+
--------
2086+
>>> idx = pd.DatetimeIndex(["2020-01-02 01:02:03.004005006"])
2087+
>>> idx.unit
2088+
'ns'
2089+
>>> idx = pd.DatetimeIndex(["2020-01-02 01:02:03"])
2090+
>>> idx.unit
2091+
's'
2092+
"""
20692093
# e.g. "ns", "us", "ms"
20702094
# error: Argument 1 to "dtype_to_unit" has incompatible type
20712095
# "ExtensionDtype"; expected "Union[DatetimeTZDtype, dtype[Any]]"

pandas/core/arrays/datetimes.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,12 +858,23 @@ def tz_convert(self, tz) -> Self:
858858
"""
859859
Convert tz-aware Datetime Array/Index from one time zone to another.
860860
861+
This method is used to convert a timezone-aware Datetime Array or Index to
862+
a different time zone. The original UTC time remains the same; only the
863+
time zone information is changed. If the Timestamp is timezone-naive, a
864+
TypeError is raised.
865+
861866
Parameters
862867
----------
863868
tz : str, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile, datetime.tzinfo or None
864869
Time zone for time. Corresponding timestamps would be converted
865870
to this time zone of the Datetime Array/Index. A `tz` of None will
866871
convert to UTC and remove the timezone information.
872+
*args
873+
Additional arguments and keywords have no effect but might be
874+
accepted for compatibility with NumPy.
875+
**kwargs
876+
Additional arguments and keywords have no effect but might be
877+
accepted for compatibility with NumPy.
867878
868879
Returns
869880
-------
@@ -985,6 +996,12 @@ def tz_localize(
985996
- timedelta objects will shift nonexistent times by the timedelta
986997
- 'raise' will raise a ValueError if there are
987998
nonexistent times.
999+
*args
1000+
Additional arguments and keywords have no effect but might be
1001+
accepted for compatibility with NumPy.
1002+
**kwargs
1003+
Additional arguments and keywords have no effect but might be
1004+
accepted for compatibility with NumPy.
9881005
9891006
Returns
9901007
-------
@@ -1204,6 +1221,12 @@ def to_period(self, freq=None) -> PeriodArray:
12041221
freq : str or Period, optional
12051222
One of pandas' :ref:`period aliases <timeseries.period_aliases>`
12061223
or an Period object. Will be inferred by default.
1224+
*args
1225+
Additional arguments and keywords have no effect but might be
1226+
accepted for compatibility with NumPy.
1227+
**kwargs
1228+
Additional arguments and keywords have no effect but might be
1229+
accepted for compatibility with NumPy.
12071230
12081231
Returns
12091232
-------

pandas/core/arrays/timedeltas.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,15 @@ def total_seconds(self) -> npt.NDArray[np.float64]:
733733
This method is available directly on TimedeltaArray, TimedeltaIndex
734734
and on Series containing timedelta values under the ``.dt`` namespace.
735735
736+
Parameters
737+
----------
738+
*args
739+
Additional arguments and keywords have no effect but might be
740+
accepted for compatibility with NumPy.
741+
**kwargs
742+
Additional arguments and keywords have no effect but might be
743+
accepted for compatibility with NumPy.
744+
736745
Returns
737746
-------
738747
ndarray, Index or Series

0 commit comments

Comments
 (0)