From 6c47e5f2fd8581c7f72fc5df2a654b06c10d5150 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Sat, 14 Mar 2020 10:47:52 -0700 Subject: [PATCH] CLN: avoid Block.get_values where it is unnecessary --- pandas/core/internals/blocks.py | 6 ++++-- pandas/core/internals/concat.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 6d4ee6222933c..4b834b79f5dfd 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -612,7 +612,9 @@ def astype(self, dtype, copy: bool = False, errors: str = "raise"): # astype formatting else: - values = self.get_values() + # Because we have neither is_extension nor is_datelike, + # self.values already has the correct shape + values = self.values else: values = self.get_values(dtype=dtype) @@ -670,7 +672,7 @@ def _can_hold_element(self, element: Any) -> bool: def to_native_types(self, slicer=None, na_rep="nan", quoting=None, **kwargs): """ convert to our native types format, slicing if desired """ - values = self.get_values() + values = self.values if slicer is not None: values = values[:, slicer] diff --git a/pandas/core/internals/concat.py b/pandas/core/internals/concat.py index 7570f6eddbd9c..6839d138fbf73 100644 --- a/pandas/core/internals/concat.py +++ b/pandas/core/internals/concat.py @@ -217,7 +217,7 @@ def get_reindexed_values(self, empty_dtype, upcasted_na): else: # No dtype upcasting is done here, it will be performed during # concatenation itself. - values = self.block.get_values() + values = self.block.values if not self.indexers: # If there's no indexing to be done, we want to signal outside