diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index a25a698856747..0f8274cfa4cd5 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -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 ------- @@ -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]]" diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 43cc492f82885..42fb39d69eabe 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -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 ------- @@ -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 ------- @@ -1204,6 +1221,12 @@ def to_period(self, freq=None) -> PeriodArray: freq : str or Period, optional One of pandas' :ref:`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 ------- diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index a8a0037d0bbb9..59716404cc2d7 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -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