Skip to content

Commit 3bfb286

Browse files
committed
1 parent 94df875 commit 3bfb286

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pandas-stubs/_libs/tslibs/timestamps.pyi

+3
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,6 @@ class Timestamp(datetime):
301301
def days_in_month(self) -> int: ...
302302
@property
303303
def daysinmonth(self) -> int: ...
304+
@property
305+
def unit(self) -> str: ...
306+
def as_unit(self, unit: str, round_ok: bool = ...) -> Timestamp: ...

tests/test_scalars.py

+3
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,7 @@ def test_timestamp_properties() -> None:
11601160
check(assert_type(ts.dayofyear, int), int)
11611161
check(assert_type(ts.days_in_month, int), int)
11621162
check(assert_type(ts.daysinmonth, int), int)
1163+
check(assert_type(ts.unit, str), str)
11631164
check(assert_type(ts.is_leap_year, bool), bool)
11641165
check(assert_type(ts.is_month_end, bool), bool)
11651166
check(assert_type(ts.is_month_start, bool), bool)
@@ -1530,6 +1531,8 @@ def test_timestamp_misc_methods() -> None:
15301531
pd.Timestamp,
15311532
)
15321533

1534+
check(assert_type(ts2.as_unit('ns'), pd.Timestamp), pd.Timestamp)
1535+
15331536
check(assert_type(ts2.round("1s"), pd.Timestamp), pd.Timestamp)
15341537
check(assert_type(ts2.round("1s", ambiguous="raise"), pd.Timestamp), pd.Timestamp)
15351538
check(assert_type(ts2.round("1s", ambiguous=True), pd.Timestamp), pd.Timestamp)

0 commit comments

Comments
 (0)