Skip to content

Commit ca55d77

Browse files
authored
DEPR: remove deprecated internals names (#58037)
* DEPR: remove deprecated internals names * mypy fixup
1 parent 724ad29 commit ca55d77

File tree

3 files changed

+3
-68
lines changed

3 files changed

+3
-68
lines changed

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ Removal of prior version deprecations/changes
235235
- Removed "freq" keyword from :class:`PeriodArray` constructor, use "dtype" instead (:issue:`52462`)
236236
- Removed 'fastpath' keyword in :class:`Categorical` constructor (:issue:`20110`)
237237
- Removed 'kind' keyword in :meth:`Series.resample` and :meth:`DataFrame.resample` (:issue:`58125`)
238+
- Removed ``Block``, ``DatetimeTZBlock``, ``ExtensionBlock``, ``create_block_manager_from_blocks`` from ``pandas.core.internals`` and ``pandas.core.internals.api`` (:issue:`55139`)
238239
- Removed alias :class:`arrays.PandasArray` for :class:`arrays.NumpyExtensionArray` (:issue:`53694`)
239240
- Removed deprecated "method" and "limit" keywords from :meth:`Series.replace` and :meth:`DataFrame.replace` (:issue:`53492`)
240241
- Removed extension test classes ``BaseNoReduceTests``, ``BaseNumericReduceTests``, ``BaseBooleanReduceTests`` (:issue:`54663`)

pandas/core/internals/api.py

+1-59
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,7 @@ def make_block(
9292

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

95-
from pandas.core.internals.blocks import (
96-
DatetimeTZBlock,
97-
ExtensionBlock,
98-
)
95+
from pandas.core.internals.blocks import ExtensionBlock
9996

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

110-
elif klass is DatetimeTZBlock and not isinstance(values.dtype, DatetimeTZDtype):
111-
# pyarrow calls get here
112-
values = DatetimeArray._simple_new(
113-
# error: Argument "dtype" to "_simple_new" of "DatetimeArray" has
114-
# incompatible type "Union[ExtensionDtype, dtype[Any], None]";
115-
# expected "Union[dtype[datetime64], DatetimeTZDtype]"
116-
values,
117-
dtype=dtype, # type: ignore[arg-type]
118-
)
119-
120107
if not isinstance(placement, BlockPlacement):
121108
placement = BlockPlacement(placement)
122109

@@ -146,48 +133,3 @@ def maybe_infer_ndim(values, placement: BlockPlacement, ndim: int | None) -> int
146133
else:
147134
ndim = values.ndim
148135
return ndim
149-
150-
151-
def __getattr__(name: str):
152-
# GH#55139
153-
import warnings
154-
155-
if name in [
156-
"Block",
157-
"ExtensionBlock",
158-
"DatetimeTZBlock",
159-
"create_block_manager_from_blocks",
160-
]:
161-
# GH#33892
162-
warnings.warn(
163-
f"{name} is deprecated and will be removed in a future version. "
164-
"Use public APIs instead.",
165-
DeprecationWarning,
166-
# https://github.com/pandas-dev/pandas/pull/55139#pullrequestreview-1720690758
167-
# on hard-coding stacklevel
168-
stacklevel=2,
169-
)
170-
171-
if name == "create_block_manager_from_blocks":
172-
from pandas.core.internals.managers import create_block_manager_from_blocks
173-
174-
return create_block_manager_from_blocks
175-
176-
elif name == "Block":
177-
from pandas.core.internals.blocks import Block
178-
179-
return Block
180-
181-
elif name == "DatetimeTZBlock":
182-
from pandas.core.internals.blocks import DatetimeTZBlock
183-
184-
return DatetimeTZBlock
185-
186-
elif name == "ExtensionBlock":
187-
from pandas.core.internals.blocks import ExtensionBlock
188-
189-
return ExtensionBlock
190-
191-
raise AttributeError(
192-
f"module 'pandas.core.internals.api' has no attribute '{name}'"
193-
)

pandas/core/internals/blocks.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -2153,14 +2153,6 @@ class DatetimeLikeBlock(NDArrayBackedExtensionBlock):
21532153
values: DatetimeArray | TimedeltaArray
21542154

21552155

2156-
class DatetimeTZBlock(DatetimeLikeBlock):
2157-
"""implement a datetime64 block with a tz attribute"""
2158-
2159-
values: DatetimeArray
2160-
2161-
__slots__ = ()
2162-
2163-
21642156
# -----------------------------------------------------------------
21652157
# Constructor Helpers
21662158

@@ -2207,7 +2199,7 @@ def get_block_type(dtype: DtypeObj) -> type[Block]:
22072199
cls : class, subclass of Block
22082200
"""
22092201
if isinstance(dtype, DatetimeTZDtype):
2210-
return DatetimeTZBlock
2202+
return DatetimeLikeBlock
22112203
elif isinstance(dtype, PeriodDtype):
22122204
return NDArrayBackedExtensionBlock
22132205
elif isinstance(dtype, ExtensionDtype):

0 commit comments

Comments
 (0)