Skip to content

Commit 7e62f07

Browse files
authored
CLN: make PeriodArray signature match DTA/TDA (pandas-dev#37289)
1 parent 8f472ae commit 7e62f07

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

doc/source/whatsnew/v1.2.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ ExtensionArray
516516
- Fixed Bug where :class:`DataFrame` column set to scalar extension type via a dict instantion was considered an object type rather than the extension type (:issue:`35965`)
517517
- Fixed bug where ``astype()`` with equal dtype and ``copy=False`` would return a new object (:issue:`284881`)
518518
- Fixed bug when applying a NumPy ufunc with multiple outputs to a :class:`pandas.arrays.IntegerArray` returning None (:issue:`36913`)
519-
519+
- Fixed an inconsistency in :class:`PeriodArray`'s ``__init__`` signature to those of :class:`DatetimeArray` and :class:`TimedeltaArray` (:issue:`37289`)
520520

521521
Other
522522
^^^^^

pandas/core/arrays/period.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ class PeriodArray(PeriodMixin, dtl.DatelikeOps):
7676
converted to ordinals without inference or copy (PeriodArray,
7777
ndarray[int64]), or a box around such an array (Series[period],
7878
PeriodIndex).
79+
dtype : PeriodDtype, optional
80+
A PeriodDtype instance from which to extract a `freq`. If both
81+
`freq` and `dtype` are specified, then the frequencies must match.
7982
freq : str or DateOffset
8083
The `freq` to use for the array. Mostly applicable when `values`
8184
is an ndarray of integers, when `freq` is required. When `values`
8285
is a PeriodArray (or box around), it's checked that ``values.freq``
8386
matches `freq`.
84-
dtype : PeriodDtype, optional
85-
A PeriodDtype instance from which to extract a `freq`. If both
86-
`freq` and `dtype` are specified, then the frequencies must match.
8787
copy : bool, default False
8888
Whether to copy the ordinals before storing.
8989
@@ -148,7 +148,7 @@ class PeriodArray(PeriodMixin, dtl.DatelikeOps):
148148
# --------------------------------------------------------------------
149149
# Constructors
150150

151-
def __init__(self, values, freq=None, dtype=None, copy=False):
151+
def __init__(self, values, dtype=None, freq=None, copy=False):
152152
freq = validate_dtype_freq(dtype, freq)
153153

154154
if freq is not None:
@@ -882,7 +882,7 @@ def period_array(
882882
if is_datetime64_dtype(data_dtype):
883883
return PeriodArray._from_datetime64(data, freq)
884884
if is_period_dtype(data_dtype):
885-
return PeriodArray(data, freq)
885+
return PeriodArray(data, freq=freq)
886886

887887
# other iterable of some kind
888888
if not isinstance(data, (np.ndarray, list, tuple, ABCSeries)):

pandas/core/indexes/period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def __new__(
214214
if data is None and ordinal is not None:
215215
# we strangely ignore `ordinal` if data is passed.
216216
ordinal = np.asarray(ordinal, dtype=np.int64)
217-
data = PeriodArray(ordinal, freq)
217+
data = PeriodArray(ordinal, freq=freq)
218218
else:
219219
# don't pass copy here, since we copy later.
220220
data = period_array(data=data, freq=freq)

0 commit comments

Comments
 (0)