From 3e396a59df68c2a388e207811f9cdf07349dcb45 Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Wed, 30 Jan 2019 06:52:47 -0800 Subject: [PATCH 1/4] Fix small typos --- pandas/_libs/interval.pyx | 1 - pandas/_libs/tslibs/nattype.pyx | 2 +- pandas/_libs/tslibs/timestamps.pyx | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/interval.pyx b/pandas/_libs/interval.pyx index 3147f36dcc835..eb511b1adb28a 100644 --- a/pandas/_libs/interval.pyx +++ b/pandas/_libs/interval.pyx @@ -18,7 +18,6 @@ cnp.import_array() cimport pandas._libs.util as util -util.import_array() from pandas._libs.hashtable cimport Int64Vector, Int64VectorData diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index a55d15a7c4e85..92cbcce6c7042 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -382,7 +382,7 @@ class NaTType(_NaT): ) combine = _make_error_func('combine', # noqa:E128 """ - Timsetamp.combine(date, time) + Timestamp.combine(date, time) date, time -> datetime with same date and time fields """ diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index fe0564cb62c30..3e6763e226a4a 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -197,7 +197,7 @@ def round_nsint64(values, mode, freq): # This is PITA. Because we inherit from datetime, which has very specific # construction requirements, we need to do object instantiation in python -# (see Timestamp class above). This will serve as a C extension type that +# (see Timestamp class below). This will serve as a C extension type that # shadows the python class, where we do any heavy lifting. cdef class _Timestamp(datetime): @@ -670,7 +670,7 @@ class Timestamp(_Timestamp): @classmethod def combine(cls, date, time): """ - Timsetamp.combine(date, time) + Timestamp.combine(date, time) date, time -> datetime with same date and time fields """ From a5696c9c2ed0f3cfe2685a1cca80d413bbace2dd Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Wed, 30 Jan 2019 06:55:38 -0800 Subject: [PATCH 2/4] no need for map_infer --- pandas/core/internals/blocks.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index df764aa4ba666..c41631424da14 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -2072,17 +2072,7 @@ def get_values(self, dtype=None): return object dtype as boxed values, such as Timestamps/Timedelta """ if is_object_dtype(dtype): - values = self.values - - if self.ndim > 1: - values = values.ravel() - - values = lib.map_infer(values, self._box_func) - - if self.ndim > 1: - values = values.reshape(self.values.shape) - - return values + return self.values.astype(object) return self.values From f44e0cac0874cc6616a857ab264dbc7e876eabbb Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Wed, 30 Jan 2019 10:10:15 -0800 Subject: [PATCH 3/4] revert --- pandas/core/internals/blocks.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index c41631424da14..df764aa4ba666 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -2072,7 +2072,17 @@ def get_values(self, dtype=None): return object dtype as boxed values, such as Timestamps/Timedelta """ if is_object_dtype(dtype): - return self.values.astype(object) + values = self.values + + if self.ndim > 1: + values = values.ravel() + + values = lib.map_infer(values, self._box_func) + + if self.ndim > 1: + values = values.reshape(self.values.shape) + + return values return self.values From d4731128ac9637d2e33dd742ddc6a4beb97ed20d Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Wed, 30 Jan 2019 10:35:03 -0800 Subject: [PATCH 4/4] make sure to wrap in holder --- pandas/core/internals/blocks.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index df764aa4ba666..36144c31dfef9 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -2072,17 +2072,9 @@ def get_values(self, dtype=None): return object dtype as boxed values, such as Timestamps/Timedelta """ if is_object_dtype(dtype): - values = self.values - - if self.ndim > 1: - values = values.ravel() - - values = lib.map_infer(values, self._box_func) - - if self.ndim > 1: - values = values.reshape(self.values.shape) - - return values + values = self.values.ravel() + result = self._holder(values).astype(object) + return result.reshape(self.values.shape) return self.values