Skip to content

PERF: skip non-consolidatable blocks when checking consolidation #32826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pandas/core/arrays/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ class SparseArray(PandasObject, ExtensionArray, ExtensionOpsMixin):
Indices: array([2, 3], dtype=int32)
"""

_pandas_ftype = "sparse"
_subtyp = "sparse_array" # register ABCSparseArray
_deprecations = PandasObject._deprecations | frozenset(["get_values"])
_sparse_index: SparseIndex
Expand Down
13 changes: 0 additions & 13 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class Block(PandasObject):
_can_consolidate = True
_verify_integrity = True
_validate_ndim = True
_ftype = "dense"
_concatenator = staticmethod(np.concatenate)

def __init__(self, values, placement, ndim=None):
Expand Down Expand Up @@ -322,14 +321,6 @@ def shape(self):
def dtype(self):
return self.values.dtype

@property
def ftype(self) -> str:
if getattr(self.values, "_pandas_ftype", False):
dtype = self.dtype.subtype
else:
dtype = self.dtype
return f"{dtype}:{self._ftype}"

def merge(self, other):
return _merge_blocks([self, other])

Expand Down Expand Up @@ -1956,10 +1947,6 @@ def where(

return [self.make_block_same_class(result, placement=self.mgr_locs)]

@property
def _ftype(self):
return getattr(self.values, "_pandas_ftype", Block._ftype)

def _unstack(self, unstacker_func, new_columns, n_rows, fill_value):
# ExtensionArray-safe unstack.
# We override ObjectBlock._unstack, which unstacks directly on the
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,8 @@ def is_consolidated(self) -> bool:
return self._is_consolidated

def _consolidate_check(self) -> None:
ftypes = [blk.ftype for blk in self.blocks]
self._is_consolidated = len(ftypes) == len(set(ftypes))
dtypes = [blk.dtype for blk in self.blocks if blk._can_consolidate]
self._is_consolidated = len(dtypes) == len(set(dtypes))
self._known_consolidated = True

@property
Expand Down