Skip to content

Commit 5193bd6

Browse files
committed
shift and asof_locs too
1 parent 82587f3 commit 5193bd6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

pandas-stubs/core/indexes/period.pyi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,18 @@ class PeriodIndex(DatetimeIndexOpsMixin[pd.Period, np.object_], PeriodIndexField
5252
def __rsub__( # pyright: ignore[reportIncompatibleMethodOverride]
5353
self, other: NaTType
5454
) -> NaTType: ...
55-
def asof_locs(self, where, mask): ...
55+
def asof_locs(
56+
self,
57+
where: pd.DatetimeIndex | PeriodIndex,
58+
mask: np.ndarray[tuple[int], np.dtype[np.bool_]],
59+
) -> Self: ...
5660
@property
5761
def is_full(self) -> bool: ...
5862
@property
5963
def inferred_type(self) -> str: ...
6064
@property
6165
def freqstr(self) -> str: ...
62-
def shift(self, periods: int = 1, freq=...) -> Self: ...
66+
def shift(self, periods: int = 1, freq: Frequency | None = None) -> Self: ...
6367

6468
def period_range(
6569
start: (

tests/test_indexes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,3 +1502,13 @@ def test_period_index_constructor() -> None:
15021502
),
15031503
pd.PeriodIndex,
15041504
)
1505+
1506+
1507+
def test_period_index_asof_locs() -> None:
1508+
idx = pd.PeriodIndex(["2000", "2001"], freq="D")
1509+
where = pd.DatetimeIndex(["2023-05-30 00:12:00", "2023-06-01 00:00:00"])
1510+
mask = np.ones(2, dtype=bool)
1511+
check(
1512+
assert_type(idx.asof_locs(where, mask), pd.PeriodIndex),
1513+
pd.PeriodIndex,
1514+
)

0 commit comments

Comments
 (0)