From 3bfb28698ffad30f50f00f6fb93c240c3be72309 Mon Sep 17 00:00:00 2001 From: Dave Tapley Date: Thu, 9 Nov 2023 18:16:05 -0700 Subject: [PATCH] Update timestamps.pyi https://github.com/pandas-dev/pandas/commit/f3c46cd0899d5e11e0602798d9390c90e51e9ba7 https://github.com/pandas-dev/pandas/pull/48819 https://github.com/pandas-dev/pandas-stubs/issues/797 --- pandas-stubs/_libs/tslibs/timestamps.pyi | 3 +++ tests/test_scalars.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pandas-stubs/_libs/tslibs/timestamps.pyi b/pandas-stubs/_libs/tslibs/timestamps.pyi index 970f8980..6952082e 100644 --- a/pandas-stubs/_libs/tslibs/timestamps.pyi +++ b/pandas-stubs/_libs/tslibs/timestamps.pyi @@ -301,3 +301,6 @@ class Timestamp(datetime): def days_in_month(self) -> int: ... @property def daysinmonth(self) -> int: ... + @property + def unit(self) -> str: ... + def as_unit(self, unit: str, round_ok: bool = ...) -> Timestamp: ... diff --git a/tests/test_scalars.py b/tests/test_scalars.py index af74019b..7f401ba1 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -1160,6 +1160,7 @@ def test_timestamp_properties() -> None: check(assert_type(ts.dayofyear, int), int) check(assert_type(ts.days_in_month, int), int) check(assert_type(ts.daysinmonth, int), int) + check(assert_type(ts.unit, str), str) check(assert_type(ts.is_leap_year, bool), bool) check(assert_type(ts.is_month_end, bool), bool) check(assert_type(ts.is_month_start, bool), bool) @@ -1530,6 +1531,8 @@ def test_timestamp_misc_methods() -> None: pd.Timestamp, ) + check(assert_type(ts2.as_unit('ns'), pd.Timestamp), pd.Timestamp) + check(assert_type(ts2.round("1s"), pd.Timestamp), pd.Timestamp) check(assert_type(ts2.round("1s", ambiguous="raise"), pd.Timestamp), pd.Timestamp) check(assert_type(ts2.round("1s", ambiguous=True), pd.Timestamp), pd.Timestamp)