Skip to content

Commit 9f58028

Browse files
mroeschkepmhatre1
authored andcommitted
CLN: ._data, PeriodIndex arguments (pandas-dev#57385)
* Remove ._data * Remove _data from StringArrow * Remove period arguments * Bump fastparquet
1 parent 066e84f commit 9f58028

21 files changed

+43
-200
lines changed

ci/deps/actions-310.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies:
2626
- beautifulsoup4>=4.11.2
2727
- blosc>=1.21.3
2828
- bottleneck>=1.3.6
29-
- fastparquet>=2022.12.0
29+
- fastparquet>=2023.04.0
3030
- fsspec>=2022.11.0
3131
- html5lib>=1.1
3232
- hypothesis>=6.46.1

ci/deps/actions-311-downstream_compat.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies:
2828
- beautifulsoup4>=4.11.2
2929
- blosc>=1.21.3
3030
- bottleneck>=1.3.6
31-
- fastparquet>=2022.12.0
31+
- fastparquet>=2023.04.0
3232
- fsspec>=2022.11.0
3333
- html5lib>=1.1
3434
- hypothesis>=6.46.1

ci/deps/actions-311.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies:
2626
- beautifulsoup4>=4.11.2
2727
- blosc>=1.21.3
2828
- bottleneck>=1.3.6
29-
- fastparquet>=2022.12.0
29+
- fastparquet>=2023.04.0
3030
- fsspec>=2022.11.0
3131
- html5lib>=1.1
3232
- hypothesis>=6.46.1

ci/deps/actions-312.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies:
2626
- beautifulsoup4>=4.11.2
2727
- blosc>=1.21.3
2828
- bottleneck>=1.3.6
29-
- fastparquet>=2022.12.0
29+
- fastparquet>=2023.04.0
3030
- fsspec>=2022.11.0
3131
- html5lib>=1.1
3232
- hypothesis>=6.46.1

ci/deps/actions-39-minimum_versions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies:
2929
- beautifulsoup4=4.11.2
3030
- blosc=1.21.3
3131
- bottleneck=1.3.6
32-
- fastparquet=2022.12.0
32+
- fastparquet=2023.04.0
3333
- fsspec=2022.11.0
3434
- html5lib=1.1
3535
- hypothesis=6.46.1

ci/deps/actions-39.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies:
2626
- beautifulsoup4>=4.11.2
2727
- blosc>=1.21.3
2828
- bottleneck>=1.3.6
29-
- fastparquet>=2022.12.0
29+
- fastparquet>=2023.04.0
3030
- fsspec>=2022.11.0
3131
- html5lib>=1.1
3232
- hypothesis>=6.46.1

ci/deps/circle-310-arm64.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies:
2727
- beautifulsoup4>=4.11.2
2828
- blosc>=1.21.3
2929
- bottleneck>=1.3.6
30-
- fastparquet>=2022.12.0
30+
- fastparquet>=2023.04.0
3131
- fsspec>=2022.11.0
3232
- html5lib>=1.1
3333
- hypothesis>=6.46.1

doc/source/getting_started/install.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ Dependency Minimum Version pip extra Notes
361361
PyTables 3.8.0 hdf5 HDF5-based reading / writing
362362
blosc 1.21.3 hdf5 Compression for HDF5; only available on ``conda``
363363
zlib hdf5 Compression for HDF5
364-
fastparquet 2022.12.0 - Parquet reading / writing (pyarrow is default)
364+
fastparquet 2023.04.0 - Parquet reading / writing (pyarrow is default)
365365
pyarrow 10.0.1 parquet, feather Parquet, ORC, and feather reading / writing
366366
pyreadstat 1.2.0 spss SPSS files (.sav) reading
367367
odfpy 1.4.1 excel Open document format (.odf, .ods, .odt) reading / writing

doc/source/whatsnew/v3.0.0.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Optional libraries below the lowest tested version may still work, but are not c
7777
+-----------------+---------------------+
7878
| Package | New Minimum Version |
7979
+=================+=====================+
80-
| | |
80+
| fastparquet | 2023.04.0 |
8181
+-----------------+---------------------+
8282

8383
See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for more.
@@ -125,6 +125,7 @@ Removal of prior version deprecations/changes
125125
- Removed ``Series.ravel`` (:issue:`56053`)
126126
- Removed ``Series.view`` (:issue:`56054`)
127127
- Removed ``StataReader.close`` (:issue:`49228`)
128+
- Removed ``_data`` from :class:`DataFrame`, :class:`Series`, :class:`.arrays.ArrowExtensionArray` (:issue:`52003`)
128129
- Removed ``axis`` argument from :meth:`DataFrame.groupby`, :meth:`Series.groupby`, :meth:`DataFrame.rolling`, :meth:`Series.rolling`, :meth:`DataFrame.resample`, and :meth:`Series.resample` (:issue:`51203`)
129130
- Removed ``axis`` argument from all groupby operations (:issue:`50405`)
130131
- Removed ``convert_dtype`` from :meth:`Series.apply` (:issue:`52257`)
@@ -134,6 +135,7 @@ Removal of prior version deprecations/changes
134135
- Removed ``pandas.value_counts``, use :meth:`Series.value_counts` instead (:issue:`53493`)
135136
- Removed ``read_gbq`` and ``DataFrame.to_gbq``. Use ``pandas_gbq.read_gbq`` and ``pandas_gbq.to_gbq`` instead https://pandas-gbq.readthedocs.io/en/latest/api.html (:issue:`55525`)
136137
- Removed ``use_nullable_dtypes`` from :func:`read_parquet` (:issue:`51853`)
138+
- Removed ``year``, ``month``, ``quarter``, ``day``, ``hour``, ``minute``, and ``second`` keywords in the :class:`PeriodIndex` constructor, use :meth:`PeriodIndex.from_fields` instead (:issue:`55960`)
137139
- Removed deprecated argument ``obj`` in :meth:`.DataFrameGroupBy.get_group` and :meth:`.SeriesGroupBy.get_group` (:issue:`53545`)
138140
- Removed deprecated behavior of :meth:`Series.agg` using :meth:`Series.apply` (:issue:`53325`)
139141
- Removed support for :class:`DataFrame` in :meth:`DataFrame.from_records`(:issue:`51697`)
@@ -142,6 +144,7 @@ Removal of prior version deprecations/changes
142144
- Removed the ``ArrayManager`` (:issue:`55043`)
143145
- Removed the ``fastpath`` argument from the :class:`Series` constructor (:issue:`55466`)
144146
- Removed the ``is_boolean``, ``is_integer``, ``is_floating``, ``holds_integer``, ``is_numeric``, ``is_categorical``, ``is_object``, and ``is_interval`` attributes of :class:`Index` (:issue:`50042`)
147+
- Removed the ``ordinal`` keyword in :class:`PeriodIndex`, use :meth:`PeriodIndex.from_ordinals` instead (:issue:`55960`)
145148
- Removed unused arguments ``*args`` and ``**kwargs`` in :class:`Resampler` methods (:issue:`50977`)
146149
- Unrecognized timezones when parsing strings to datetimes now raises a ``ValueError`` (:issue:`51477`)
147150

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies:
2929
- beautifulsoup4>=4.11.2
3030
- blosc
3131
- bottleneck>=1.3.6
32-
- fastparquet>=2022.12.0
32+
- fastparquet>=2023.04.0
3333
- fsspec>=2022.11.0
3434
- html5lib>=1.1
3535
- hypothesis>=6.46.1

pandas/compat/_optional.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"blosc": "1.21.3",
2626
"bottleneck": "1.3.6",
2727
"dataframe-api-compat": "0.1.7",
28-
"fastparquet": "2022.12.0",
28+
"fastparquet": "2023.04.0",
2929
"fsspec": "2022.11.0",
3030
"html5lib": "1.1",
3131
"hypothesis": "6.46.1",

pandas/core/arrays/string_arrow.py

-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
Union,
1010
cast,
1111
)
12-
import warnings
1312

1413
import numpy as np
1514

@@ -21,7 +20,6 @@
2120
pa_version_under10p1,
2221
pa_version_under13p0,
2322
)
24-
from pandas.util._exceptions import find_stack_level
2523

2624
from pandas.core.dtypes.common import (
2725
is_bool_dtype,
@@ -272,17 +270,6 @@ def astype(self, dtype, copy: bool = True):
272270

273271
return super().astype(dtype, copy=copy)
274272

275-
@property
276-
def _data(self):
277-
# dask accesses ._data directlys
278-
warnings.warn(
279-
f"{type(self).__name__}._data is a deprecated and will be removed "
280-
"in a future version, use ._pa_array instead",
281-
FutureWarning,
282-
stacklevel=find_stack_level(),
283-
)
284-
return self._pa_array
285-
286273
# ------------------------------------------------------------------------
287274
# String methods interface
288275

pandas/core/generic.py

-17
Original file line numberDiff line numberDiff line change
@@ -486,23 +486,6 @@ def _constructor(self) -> Callable[..., Self]:
486486
"""
487487
raise AbstractMethodError(self)
488488

489-
# ----------------------------------------------------------------------
490-
# Internals
491-
492-
@final
493-
@property
494-
def _data(self):
495-
# GH#33054 retained because some downstream packages uses this,
496-
# e.g. fastparquet
497-
# GH#33333
498-
warnings.warn(
499-
f"{type(self).__name__}._data is deprecated and will be removed in "
500-
"a future version. Use public APIs instead.",
501-
DeprecationWarning,
502-
stacklevel=find_stack_level(),
503-
)
504-
return self._mgr
505-
506489
# ----------------------------------------------------------------------
507490
# Axis
508491
_AXIS_ORDERS: list[Literal["index", "columns"]]

pandas/core/indexes/period.py

+10-77
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
timedelta,
66
)
77
from typing import TYPE_CHECKING
8-
import warnings
98

109
import numpy as np
1110

@@ -22,7 +21,6 @@
2221
cache_readonly,
2322
doc,
2423
)
25-
from pandas.util._exceptions import find_stack_level
2624

2725
from pandas.core.dtypes.common import is_integer
2826
from pandas.core.dtypes.dtypes import PeriodDtype
@@ -94,11 +92,6 @@ class PeriodIndex(DatetimeIndexOpsMixin):
9492
----------
9593
data : array-like (1d int np.ndarray or PeriodArray), optional
9694
Optional period-like data to construct index with.
97-
ordinal : array-like of int, optional
98-
The period offsets from the proleptic Gregorian epoch.
99-
100-
.. deprecated:: 2.2.0
101-
Use PeriodIndex.from_ordinals instead.
10295
freq : str or period object, optional
10396
One of pandas period strings or corresponding objects.
10497
dtype : str or PeriodDtype, default None
@@ -107,11 +100,6 @@ class PeriodIndex(DatetimeIndexOpsMixin):
107100
Make a copy of input ndarray.
108101
name : str, default None
109102
Name of the resulting PeriodIndex.
110-
**fields : optional
111-
Date fields such as year, month, etc.
112-
113-
.. deprecated:: 2.2.0
114-
Use PeriodIndex.from_fields instead.
115103
116104
Attributes
117105
----------
@@ -219,84 +207,29 @@ def second(self) -> Index:
219207
def __new__(
220208
cls,
221209
data=None,
222-
ordinal=None,
223210
freq=None,
224211
dtype: Dtype | None = None,
225212
copy: bool = False,
226213
name: Hashable | None = None,
227-
**fields,
228214
) -> Self:
229-
valid_field_set = {
230-
"year",
231-
"month",
232-
"day",
233-
"quarter",
234-
"hour",
235-
"minute",
236-
"second",
237-
}
238-
239215
refs = None
240216
if not copy and isinstance(data, (Index, ABCSeries)):
241217
refs = data._references
242218

243-
if not set(fields).issubset(valid_field_set):
244-
argument = next(iter(set(fields) - valid_field_set))
245-
raise TypeError(f"__new__() got an unexpected keyword argument {argument}")
246-
elif len(fields):
247-
# GH#55960
248-
warnings.warn(
249-
"Constructing PeriodIndex from fields is deprecated. Use "
250-
"PeriodIndex.from_fields instead.",
251-
FutureWarning,
252-
stacklevel=find_stack_level(),
253-
)
254-
255-
if ordinal is not None:
256-
# GH#55960
257-
warnings.warn(
258-
"The 'ordinal' keyword in PeriodIndex is deprecated and will "
259-
"be removed in a future version. Use PeriodIndex.from_ordinals "
260-
"instead.",
261-
FutureWarning,
262-
stacklevel=find_stack_level(),
263-
)
264-
265219
name = maybe_extract_name(name, data, cls)
266220

267-
if data is None and ordinal is None:
268-
# range-based.
269-
if not fields:
270-
# test_pickle_compat_construction
271-
cls._raise_scalar_data_error(None)
272-
data = cls.from_fields(**fields, freq=freq)._data
273-
copy = False
221+
freq = validate_dtype_freq(dtype, freq)
274222

275-
elif fields:
276-
if data is not None:
277-
raise ValueError("Cannot pass both data and fields")
278-
raise ValueError("Cannot pass both ordinal and fields")
223+
# PeriodIndex allow PeriodIndex(period_index, freq=different)
224+
# Let's not encourage that kind of behavior in PeriodArray.
279225

280-
else:
281-
freq = validate_dtype_freq(dtype, freq)
282-
283-
# PeriodIndex allow PeriodIndex(period_index, freq=different)
284-
# Let's not encourage that kind of behavior in PeriodArray.
285-
286-
if freq and isinstance(data, cls) and data.freq != freq:
287-
# TODO: We can do some of these with no-copy / coercion?
288-
# e.g. D -> 2D seems to be OK
289-
data = data.asfreq(freq)
290-
291-
if data is None and ordinal is not None:
292-
ordinal = np.asarray(ordinal, dtype=np.int64)
293-
dtype = PeriodDtype(freq)
294-
data = PeriodArray(ordinal, dtype=dtype)
295-
elif data is not None and ordinal is not None:
296-
raise ValueError("Cannot pass both data and ordinal")
297-
else:
298-
# don't pass copy here, since we copy later.
299-
data = period_array(data=data, freq=freq)
226+
if freq and isinstance(data, cls) and data.freq != freq:
227+
# TODO: We can do some of these with no-copy / coercion?
228+
# e.g. D -> 2D seems to be OK
229+
data = data.asfreq(freq)
230+
231+
# don't pass copy here, since we copy later.
232+
data = period_array(data=data, freq=freq)
300233

301234
if copy:
302235
data = data.copy()

pandas/tests/frame/test_api.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,4 @@ def test_inspect_getmembers(self):
376376
# GH38740
377377
pytest.importorskip("jinja2")
378378
df = DataFrame()
379-
msg = "DataFrame._data is deprecated"
380-
with tm.assert_produces_warning(
381-
DeprecationWarning, match=msg, check_stacklevel=False
382-
):
383-
inspect.getmembers(df)
379+
inspect.getmembers(df)

pandas/tests/generic/test_generic.py

-7
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,6 @@ def test_copy_and_deepcopy(self, frame_or_series, shape, func):
303303
assert obj_copy is not obj
304304
tm.assert_equal(obj_copy, obj)
305305

306-
def test_data_deprecated(self, frame_or_series):
307-
obj = frame_or_series()
308-
msg = "(Series|DataFrame)._data is deprecated"
309-
with tm.assert_produces_warning(DeprecationWarning, match=msg):
310-
mgr = obj._data
311-
assert mgr is obj._mgr
312-
313306

314307
class TestNDFrame:
315308
# tests that don't fit elsewhere

0 commit comments

Comments
 (0)