Skip to content

Commit ee07fa8

Browse files
jbrockmendelpmhatre1
authored andcommitted
DEPR: freq keyword in PeriodArray (pandas-dev#58022)
* DEPR: freq keyword in PeriodArray * update docstring
1 parent 4abb8bf commit ee07fa8

File tree

3 files changed

+2
-31
lines changed

3 files changed

+2
-31
lines changed

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ Removal of prior version deprecations/changes
206206
- :meth:`SeriesGroupBy.agg` no longer pins the name of the group to the input passed to the provided ``func`` (:issue:`51703`)
207207
- All arguments except ``name`` in :meth:`Index.rename` are now keyword only (:issue:`56493`)
208208
- All arguments except the first ``path``-like argument in IO writers are now keyword only (:issue:`54229`)
209+
- Removed "freq" keyword from :class:`PeriodArray` constructor, use "dtype" instead (:issue:`52462`)
209210
- Removed the "closed" and "normalize" keywords in :meth:`DatetimeIndex.__new__` (:issue:`52628`)
210211
- Removed the "closed" and "unit" keywords in :meth:`TimedeltaIndex.__new__` (:issue:`52628`, :issue:`55499`)
211212
- All arguments in :meth:`Index.sort_values` are now keyword only (:issue:`56493`)

pandas/core/arrays/period.py

+1-20
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
cache_readonly,
5555
doc,
5656
)
57-
from pandas.util._exceptions import find_stack_level
5857

5958
from pandas.core.dtypes.common import (
6059
ensure_object,
@@ -135,11 +134,6 @@ class PeriodArray(dtl.DatelikeOps, libperiod.PeriodMixin): # type: ignore[misc]
135134
dtype : PeriodDtype, optional
136135
A PeriodDtype instance from which to extract a `freq`. If both
137136
`freq` and `dtype` are specified, then the frequencies must match.
138-
freq : str or DateOffset
139-
The `freq` to use for the array. Mostly applicable when `values`
140-
is an ndarray of integers, when `freq` is required. When `values`
141-
is a PeriodArray (or box around), it's checked that ``values.freq``
142-
matches `freq`.
143137
copy : bool, default False
144138
Whether to copy the ordinals before storing.
145139
@@ -224,20 +218,7 @@ def _scalar_type(self) -> type[Period]:
224218
# --------------------------------------------------------------------
225219
# Constructors
226220

227-
def __init__(
228-
self, values, dtype: Dtype | None = None, freq=None, copy: bool = False
229-
) -> None:
230-
if freq is not None:
231-
# GH#52462
232-
warnings.warn(
233-
"The 'freq' keyword in the PeriodArray constructor is deprecated "
234-
"and will be removed in a future version. Pass 'dtype' instead",
235-
FutureWarning,
236-
stacklevel=find_stack_level(),
237-
)
238-
freq = validate_dtype_freq(dtype, freq)
239-
dtype = PeriodDtype(freq)
240-
221+
def __init__(self, values, dtype: Dtype | None = None, copy: bool = False) -> None:
241222
if dtype is not None:
242223
dtype = pandas_dtype(dtype)
243224
if not isinstance(dtype, PeriodDtype):

pandas/tests/arrays/period/test_constructors.py

-11
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,6 @@ def test_from_td64nat_sequence_raises():
135135
pd.DataFrame(arr, dtype=dtype)
136136

137137

138-
def test_freq_deprecated():
139-
# GH#52462
140-
data = np.arange(5).astype(np.int64)
141-
msg = "The 'freq' keyword in the PeriodArray constructor is deprecated"
142-
with tm.assert_produces_warning(FutureWarning, match=msg):
143-
res = PeriodArray(data, freq="M")
144-
145-
expected = PeriodArray(data, dtype="period[M]")
146-
tm.assert_equal(res, expected)
147-
148-
149138
def test_period_array_from_datetime64():
150139
arr = np.array(
151140
["2020-01-01T00:00:00", "2020-02-02T00:00:00"], dtype="datetime64[ns]"

0 commit comments

Comments
 (0)