diff --git a/asv_bench/benchmarks/frame_methods.py b/asv_bench/benchmarks/frame_methods.py index a3aff45afa116..44f71b392c0eb 100644 --- a/asv_bench/benchmarks/frame_methods.py +++ b/asv_bench/benchmarks/frame_methods.py @@ -564,7 +564,7 @@ def setup(self): def time_frame_get_dtype_counts(self): with warnings.catch_warnings(record=True): - self.df._data.get_dtype_counts() + self.df.dtypes.value_counts() def time_info(self): self.df.info() diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index 12e553cbd7ca4..485180b031e03 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -74,7 +74,6 @@ class BlockManager(PandasObject): set_axis(axis, new_labels) copy(deep=True) - get_dtype_counts get_dtypes apply(func, axes, block_filter_fn) @@ -256,18 +255,6 @@ def _rebuild_blknos_and_blklocs(self) -> None: def items(self) -> Index: return self.axes[0] - def _get_counts(self, f): - """ return a dict of the counts of the function in BlockManager """ - self._consolidate_inplace() - counts = dict() - for b in self.blocks: - v = f(b) - counts[v] = counts.get(v, 0) + b.shape[0] - return counts - - def get_dtype_counts(self): - return self._get_counts(lambda b: b.dtype.name) - def get_dtypes(self): dtypes = np.array([blk.dtype for blk in self.blocks]) return algos.take_1d(dtypes, self.blknos, allow_fill=False) @@ -1530,9 +1517,6 @@ def index(self) -> Index: def dtype(self) -> DtypeObj: return self._block.dtype - def get_dtype_counts(self): - return {self.dtype.name: 1} - def get_dtypes(self) -> np.ndarray: return np.array([self._block.dtype])