Skip to content

Commit ae2bb5d

Browse files
jbrockmendelclaude
andcommitted
DEPR: PeriodIndex.is_full
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 48295cd commit ae2bb5d

3 files changed

Lines changed: 44 additions & 15 deletions

File tree

doc/source/whatsnew/v3.1.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Other API changes
9797

9898
Deprecations
9999
~~~~~~~~~~~~
100+
- Deprecated :attr:`PeriodIndex.is_full` (:issue:`64938`)
100101
- Deprecated :attr:`Timestamp.dayofweek`, :attr:`Timestamp.dayofyear`, :attr:`Timestamp.daysinmonth` in favor of :attr:`Timestamp.day_of_week`, :attr:`Timestamp.day_of_year`, :attr:`Timestamp.days_in_month`, respectively. The same deprecation applies to the corresponding attributes on :class:`Period`, :class:`DatetimeIndex`, :class:`PeriodIndex`, and :attr:`Series.dt` (:issue:`46768`)
101102
- Deprecated :meth:`.DataFrameGroupBy.agg` and :meth:`.Resampler.agg` unpacking a scalar when the provided ``func`` returns a Series or array of length 1; in the future this will result in the Series or array being in the result. Users should unpack the scalar in ``func`` itself (:issue:`64014`)
102103
- Deprecated :meth:`ExcelFile.parse`, use :func:`read_excel` instead (:issue:`58247`)

pandas/core/indexes/period.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
TYPE_CHECKING,
99
Self,
1010
)
11+
import warnings
1112

1213
import numpy as np
1314

@@ -22,10 +23,12 @@
2223
to_offset,
2324
)
2425
from pandas._libs.tslibs.dtypes import OFFSET_TO_PERIOD_FREQSTR
26+
from pandas.errors import Pandas4Warning
2527
from pandas.util._decorators import (
2628
cache_readonly,
2729
set_module,
2830
)
31+
from pandas.util._exceptions import find_stack_level
2932

3033
from pandas.core.dtypes.common import (
3134
is_integer,
@@ -567,9 +570,19 @@ def asof_locs(self, where: Index, mask: npt.NDArray[np.bool_]) -> np.ndarray:
567570
@property
568571
def is_full(self) -> bool:
569572
"""
570-
Returns True if this PeriodIndex is range-like in that all Periods
571-
between start and end are present, in order.
573+
Returns True if this PeriodIndex is monotonic increasing and has
574+
no gaps, allowing duplicates.
575+
576+
.. deprecated:: 3.1.0
577+
PeriodIndex.is_full is deprecated and will be removed in
578+
a future version.
572579
"""
580+
warnings.warn(
581+
"PeriodIndex.is_full is deprecated and will be removed in a "
582+
"future version.",
583+
Pandas4Warning,
584+
stacklevel=find_stack_level(),
585+
)
573586
if len(self) == 0:
574587
return True
575588
if not self.is_monotonic_increasing:
Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
11
import pytest
22

3+
from pandas.errors import Pandas4Warning
4+
35
from pandas import PeriodIndex
6+
import pandas._testing as tm
7+
8+
msg = "PeriodIndex.is_full is deprecated"
49

510

6-
def test_is_full():
7-
index = PeriodIndex([2005, 2007, 2009], freq="Y")
8-
assert not index.is_full
11+
class TestIsFull:
12+
def test_is_full(self):
13+
index = PeriodIndex([2005, 2007, 2009], freq="Y")
14+
with tm.assert_produces_warning(Pandas4Warning, match=msg):
15+
assert not index.is_full
916

10-
index = PeriodIndex([2005, 2006, 2007], freq="Y")
11-
assert index.is_full
17+
index = PeriodIndex([2005, 2006, 2007], freq="Y")
18+
with tm.assert_produces_warning(Pandas4Warning, match=msg):
19+
assert index.is_full
1220

13-
index = PeriodIndex([2005, 2005, 2007], freq="Y")
14-
assert not index.is_full
21+
index = PeriodIndex([2005, 2005, 2007], freq="Y")
22+
with tm.assert_produces_warning(Pandas4Warning, match=msg):
23+
assert not index.is_full
1524

16-
index = PeriodIndex([2005, 2005, 2006], freq="Y")
17-
assert index.is_full
25+
index = PeriodIndex([2005, 2005, 2006], freq="Y")
26+
with tm.assert_produces_warning(Pandas4Warning, match=msg):
27+
assert index.is_full
1828

19-
index = PeriodIndex([2006, 2005, 2005], freq="Y")
20-
with pytest.raises(ValueError, match="Index is not monotonic"):
21-
index.is_full
29+
def test_is_full_not_monotonic(self):
30+
index = PeriodIndex([2006, 2005, 2005], freq="Y")
31+
with pytest.raises(ValueError, match="Index is not monotonic"):
32+
with tm.assert_produces_warning(Pandas4Warning, match=msg):
33+
index.is_full
2234

23-
assert index[:0].is_full
35+
def test_is_full_empty(self):
36+
index = PeriodIndex([], freq="Y")
37+
with tm.assert_produces_warning(Pandas4Warning, match=msg):
38+
assert index.is_full

0 commit comments

Comments
 (0)