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)