Skip to content

Commit 231f54c

Browse files
jbrockmendelSeeminSyed
authored andcommitted
CLN: remove Block.array_dtype, SingleBlockManager.array_dtype (pandas-dev#32612)
1 parent 78a26a0 commit 231f54c

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

pandas/core/internals/blocks.py

-17
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import pandas._libs.internals as libinternals
1212
from pandas._libs.tslibs import Timedelta, conversion
1313
from pandas._libs.tslibs.timezones import tz_compare
14-
from pandas._typing import DtypeObj
1514
from pandas.util._validators import validate_bool_kwarg
1615

1716
from pandas.core.dtypes.cast import (
@@ -256,14 +255,6 @@ def mgr_locs(self, new_mgr_locs):
256255

257256
self._mgr_locs = new_mgr_locs
258257

259-
@property
260-
def array_dtype(self) -> DtypeObj:
261-
"""
262-
the dtype to return if I want to construct this block as an
263-
array
264-
"""
265-
return self.dtype
266-
267258
def make_block(self, values, placement=None) -> "Block":
268259
"""
269260
Create a new block, with type inference propagate any values that are
@@ -2921,14 +2912,6 @@ def __init__(self, values, placement, ndim=None):
29212912
def _holder(self):
29222913
return Categorical
29232914

2924-
@property
2925-
def array_dtype(self):
2926-
"""
2927-
the dtype to return if I want to construct this block as an
2928-
array
2929-
"""
2930-
return np.object_
2931-
29322915
def to_dense(self):
29332916
# Categorical.get_values returns a DatetimeIndex for datetime
29342917
# categories, so we can't simply use `np.asarray(self.values)` like

pandas/core/internals/managers.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ def make_empty(self: T, axes=None) -> T:
193193
# preserve dtype if possible
194194
if self.ndim == 1:
195195
assert isinstance(self, SingleBlockManager) # for mypy
196-
arr = np.array([], dtype=self.array_dtype)
197-
blocks = [make_block(arr, placement=slice(0, 0), ndim=1)]
196+
blk = self.blocks[0]
197+
arr = blk.values[:0]
198+
nb = blk.make_block_same_class(arr, placement=slice(0, 0), ndim=1)
199+
blocks = [nb]
198200
else:
199201
blocks = []
200202
return type(self).from_blocks(blocks, axes)
@@ -1585,10 +1587,6 @@ def index(self) -> Index:
15851587
def dtype(self) -> DtypeObj:
15861588
return self._block.dtype
15871589

1588-
@property
1589-
def array_dtype(self) -> DtypeObj:
1590-
return self._block.array_dtype
1591-
15921590
def get_dtype_counts(self):
15931591
return {self.dtype.name: 1}
15941592

0 commit comments

Comments
 (0)