Skip to content

Commit

Permalink
DEPR: remove deprecated internals names (#58037)
Browse files Browse the repository at this point in the history
* DEPR: remove deprecated internals names

* mypy fixup
  • Loading branch information
jbrockmendel authored May 8, 2024
1 parent 724ad29 commit ca55d77
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 68 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ Removal of prior version deprecations/changes
- Removed "freq" keyword from :class:`PeriodArray` constructor, use "dtype" instead (:issue:`52462`)
- Removed 'fastpath' keyword in :class:`Categorical` constructor (:issue:`20110`)
- Removed 'kind' keyword in :meth:`Series.resample` and :meth:`DataFrame.resample` (:issue:`58125`)
- Removed ``Block``, ``DatetimeTZBlock``, ``ExtensionBlock``, ``create_block_manager_from_blocks`` from ``pandas.core.internals`` and ``pandas.core.internals.api`` (:issue:`55139`)
- Removed alias :class:`arrays.PandasArray` for :class:`arrays.NumpyExtensionArray` (:issue:`53694`)
- Removed deprecated "method" and "limit" keywords from :meth:`Series.replace` and :meth:`DataFrame.replace` (:issue:`53492`)
- Removed extension test classes ``BaseNoReduceTests``, ``BaseNumericReduceTests``, ``BaseBooleanReduceTests`` (:issue:`54663`)
Expand Down
60 changes: 1 addition & 59 deletions pandas/core/internals/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ def make_block(

values, dtype = extract_pandas_array(values, dtype, ndim)

from pandas.core.internals.blocks import (
DatetimeTZBlock,
ExtensionBlock,
)
from pandas.core.internals.blocks import ExtensionBlock

if klass is ExtensionBlock and isinstance(values.dtype, PeriodDtype):
# GH-44681 changed PeriodArray to be stored in the 2D
Expand All @@ -107,16 +104,6 @@ def make_block(
dtype = dtype or values.dtype
klass = get_block_type(dtype)

elif klass is DatetimeTZBlock and not isinstance(values.dtype, DatetimeTZDtype):
# pyarrow calls get here
values = DatetimeArray._simple_new(
# error: Argument "dtype" to "_simple_new" of "DatetimeArray" has
# incompatible type "Union[ExtensionDtype, dtype[Any], None]";
# expected "Union[dtype[datetime64], DatetimeTZDtype]"
values,
dtype=dtype, # type: ignore[arg-type]
)

if not isinstance(placement, BlockPlacement):
placement = BlockPlacement(placement)

Expand Down Expand Up @@ -146,48 +133,3 @@ def maybe_infer_ndim(values, placement: BlockPlacement, ndim: int | None) -> int
else:
ndim = values.ndim
return ndim


def __getattr__(name: str):
# GH#55139
import warnings

if name in [
"Block",
"ExtensionBlock",
"DatetimeTZBlock",
"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,
)

if name == "create_block_manager_from_blocks":
from pandas.core.internals.managers import create_block_manager_from_blocks

return create_block_manager_from_blocks

elif name == "Block":
from pandas.core.internals.blocks import Block

return Block

elif name == "DatetimeTZBlock":
from pandas.core.internals.blocks import DatetimeTZBlock

return DatetimeTZBlock

elif name == "ExtensionBlock":
from pandas.core.internals.blocks import ExtensionBlock

return ExtensionBlock

raise AttributeError(
f"module 'pandas.core.internals.api' has no attribute '{name}'"
)
10 changes: 1 addition & 9 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2153,14 +2153,6 @@ class DatetimeLikeBlock(NDArrayBackedExtensionBlock):
values: DatetimeArray | TimedeltaArray


class DatetimeTZBlock(DatetimeLikeBlock):
"""implement a datetime64 block with a tz attribute"""

values: DatetimeArray

__slots__ = ()


# -----------------------------------------------------------------
# Constructor Helpers

Expand Down Expand Up @@ -2207,7 +2199,7 @@ def get_block_type(dtype: DtypeObj) -> type[Block]:
cls : class, subclass of Block
"""
if isinstance(dtype, DatetimeTZDtype):
return DatetimeTZBlock
return DatetimeLikeBlock
elif isinstance(dtype, PeriodDtype):
return NDArrayBackedExtensionBlock
elif isinstance(dtype, ExtensionDtype):
Expand Down

0 comments on commit ca55d77

Please sign in to comment.