diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index c77348b365370..2c85245c4f4c8 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -250,6 +250,7 @@ Removal of prior version deprecations/changes - Enforced deprecation of :meth:`Series.interpolate` and :meth:`DataFrame.interpolate` for object-dtype (:issue:`57820`) - Enforced deprecation of :meth:`offsets.Tick.delta`, use ``pd.Timedelta(obj)`` instead (:issue:`55498`) - Enforced deprecation of ``axis=None`` acting the same as ``axis=0`` in the DataFrame reductions ``sum``, ``prod``, ``std``, ``var``, and ``sem``, passing ``axis=None`` will now reduce over both axes; this is particularly the case when doing e.g. ``numpy.sum(df)`` (:issue:`21597`) +- Enforced deprecation of ``core.internals`` members ``Block``, ``ExtensionBlock``, and ``DatetimeTZBlock`` (:issue:`58467`) - Enforced deprecation of non-standard (``np.ndarray``, :class:`ExtensionArray`, :class:`Index`, or :class:`Series`) argument to :func:`api.extensions.take` (:issue:`52981`) - Enforced deprecation of parsing system timezone strings to ``tzlocal``, which depended on system timezone, pass the 'tz' keyword instead (:issue:`50791`) - Enforced deprecation of passing a dictionary to :meth:`SeriesGroupBy.agg` (:issue:`52268`) diff --git a/pandas/core/internals/__init__.py b/pandas/core/internals/__init__.py index 89c8a4a27ca31..45758379e0bd6 100644 --- a/pandas/core/internals/__init__.py +++ b/pandas/core/internals/__init__.py @@ -6,58 +6,8 @@ ) __all__ = [ - "Block", - "DatetimeTZBlock", - "ExtensionBlock", "make_block", "BlockManager", "SingleBlockManager", "concatenate_managers", ] - - -def __getattr__(name: str): - # GH#55139 - import warnings - - if name == "create_block_manager_from_blocks": - # GH#33892 - warnings.warn( - f"{name} is deprecated and will be removed in a future version. " - "Use public APIs instead.", - DeprecationWarning, - # https://github.com/pandas-dev/pandas/pull/55139#pullrequestreview-1720690758 - # on hard-coding stacklevel - stacklevel=2, - ) - from pandas.core.internals.managers import create_block_manager_from_blocks - - return create_block_manager_from_blocks - - if name in [ - "Block", - "ExtensionBlock", - "DatetimeTZBlock", - ]: - warnings.warn( - f"{name} is deprecated and will be removed in a future version. " - "Use public APIs instead.", - DeprecationWarning, - # https://github.com/pandas-dev/pandas/pull/55139#pullrequestreview-1720690758 - # on hard-coding stacklevel - stacklevel=2, - ) - if name == "DatetimeTZBlock": - from pandas.core.internals.blocks import DatetimeTZBlock - - return DatetimeTZBlock - elif name == "ExtensionBlock": - from pandas.core.internals.blocks import ExtensionBlock - - return ExtensionBlock - else: - from pandas.core.internals.blocks import Block - - return Block - - raise AttributeError(f"module 'pandas.core.internals' has no attribute '{name}'") diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index d585c59dd5581..8a006639ed28e 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -124,7 +124,8 @@ npt, ) - from pandas.core.internals import Block + from pandas.core.internals.blocks import Block + # versioning attribute _version = "0.15.2" diff --git a/pandas/tests/internals/test_api.py b/pandas/tests/internals/test_api.py index 7ab8988521fdf..c189d5248b1f3 100644 --- a/pandas/tests/internals/test_api.py +++ b/pandas/tests/internals/test_api.py @@ -41,21 +41,6 @@ def test_namespace(): assert set(result) == set(expected + modules) -@pytest.mark.parametrize( - "name", - [ - "Block", - "ExtensionBlock", - "DatetimeTZBlock", - ], -) -def test_deprecations(name): - # GH#55139 - msg = f"{name} is deprecated.* Use public APIs instead" - with tm.assert_produces_warning(DeprecationWarning, match=msg): - getattr(internals, name) - - def test_make_block_2d_with_dti(): # GH#41168 dti = pd.date_range("2012", periods=3, tz="UTC") @@ -65,18 +50,6 @@ def test_make_block_2d_with_dti(): assert blk.values.shape == (1, 3) -def test_create_block_manager_from_blocks_deprecated(): - # GH#33892 - # If they must, downstream packages should get this from internals.api, - # not internals. - msg = ( - "create_block_manager_from_blocks is deprecated and will be " - "removed in a future version. Use public APIs instead" - ) - with tm.assert_produces_warning(DeprecationWarning, match=msg): - internals.create_block_manager_from_blocks - - def test_create_dataframe_from_blocks(float_frame): block = float_frame._mgr.blocks[0] index = float_frame.index.copy() diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index 55be48eb572fd..2860b3a6483af 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -655,6 +655,7 @@ def test_read_empty_array(self, pa, dtype): "value": pd.array([], dtype=dtype), } ) + pytest.importorskip("pyarrow", "11.0.0") # GH 45694 expected = None if dtype == "float": @@ -671,6 +672,7 @@ def test_read_empty_array(self, pa, dtype): class TestParquetPyArrow(Base): def test_basic(self, pa, df_full): df = df_full + pytest.importorskip("pyarrow", "11.0.0") # additional supported types for pyarrow dti = pd.date_range("20130101", periods=3, tz="Europe/Brussels") @@ -938,6 +940,8 @@ def test_timestamp_nanoseconds(self, pa): check_round_trip(df, pa, write_kwargs={"version": ver}) def test_timezone_aware_index(self, request, pa, timezone_aware_date_list): + pytest.importorskip("pyarrow", "11.0.0") + if timezone_aware_date_list.tzinfo != datetime.timezone.utc: request.applymarker( pytest.mark.xfail(