Skip to content

Commit a75cde3

Browse files
committed
fix: Series.dt argument 'ambiguous'
1 parent 6db30fc commit a75cde3

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

pandas-stubs/core/indexes/accessors.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]):
167167
def round(
168168
self,
169169
freq: str | BaseOffset | None,
170-
ambiguous: Literal["raise", "infer", "NaT"] | np_ndarray_bool = ...,
170+
ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = ...,
171171
nonexistent: (
172172
Literal["shift_forward", "shift_backward", "NaT", "raise"]
173173
| timedelta
@@ -177,7 +177,7 @@ class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]):
177177
def floor(
178178
self,
179179
freq: str | BaseOffset | None,
180-
ambiguous: Literal["raise", "infer", "NaT"] | np_ndarray_bool = ...,
180+
ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = ...,
181181
nonexistent: (
182182
Literal["shift_forward", "shift_backward", "NaT", "raise"]
183183
| timedelta
@@ -187,7 +187,7 @@ class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]):
187187
def ceil(
188188
self,
189189
freq: str | BaseOffset | None,
190-
ambiguous: Literal["raise", "infer", "NaT"] | np_ndarray_bool = ...,
190+
ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = ...,
191191
nonexistent: (
192192
Literal["shift_forward", "shift_backward", "NaT", "raise"]
193193
| timedelta

tests/test_timefuncs.py

+15
Original file line numberDiff line numberDiff line change
@@ -489,16 +489,31 @@ def test_series_dt_accessors() -> None:
489489
pd.Series,
490490
pd.Timestamp,
491491
)
492+
check(
493+
assert_type(s0.dt.round("D", ambiguous=False), "TimestampSeries"),
494+
pd.Series,
495+
pd.Timestamp,
496+
)
492497
check(
493498
assert_type(s0.dt.floor("D", nonexistent=dt.timedelta(1)), "TimestampSeries"),
494499
pd.Series,
495500
pd.Timestamp,
496501
)
502+
check(
503+
assert_type(s0.dt.floor("D", ambiguous=False), "TimestampSeries"),
504+
pd.Series,
505+
pd.Timestamp,
506+
)
497507
check(
498508
assert_type(s0.dt.ceil("D", nonexistent=dt.timedelta(1)), "TimestampSeries"),
499509
pd.Series,
500510
pd.Timestamp,
501511
)
512+
check(
513+
assert_type(s0.dt.ceil("D", ambiguous=False), "TimestampSeries"),
514+
pd.Series,
515+
pd.Timestamp,
516+
)
502517
check(assert_type(s0.dt.month_name(), "pd.Series[str]"), pd.Series, str)
503518
check(assert_type(s0.dt.day_name(), "pd.Series[str]"), pd.Series, str)
504519
check(assert_type(s0.dt.unit, TimeUnit), str)

0 commit comments

Comments
 (0)