diff --git a/ci/code_checks.sh b/ci/code_checks.sh index c2ab1e6b62352..1e90c16377467 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -92,12 +92,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.dt.month_name PR01,PR02" \ -i "pandas.Series.dt.normalize PR01" \ -i "pandas.Series.dt.round PR01,PR02" \ - -i "pandas.Series.dt.strftime PR01,PR02" \ - -i "pandas.Series.dt.to_period PR01,PR02" \ - -i "pandas.Series.dt.total_seconds PR01" \ - -i "pandas.Series.dt.tz_convert PR01,PR02" \ - -i "pandas.Series.dt.tz_localize PR01,PR02" \ - -i "pandas.Series.dt.unit GL08" \ + -i "pandas.Series.dt.strftime PR02" \ + -i "pandas.Series.dt.to_period PR02" \ + -i "pandas.Series.dt.tz_convert PR02" \ + -i "pandas.Series.dt.tz_localize PR02" \ -i "pandas.Series.pad PR01,SA01" \ -i "pandas.Series.sparse.fill_value SA01" \ -i "pandas.Series.sparse.from_coo PR07,SA01" \ diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index fbe1677b95b33..515c7dd2de595 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1736,6 +1736,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 ------- @@ -2060,6 +2066,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 201c449185057..5d6c8a596e5c7 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -854,12 +854,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 ------- @@ -981,6 +992,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 ------- @@ -1200,6 +1217,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 754ae277e359a..c64262e00916b 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