From 143fdf1f15f169432c16996d9ab4ce2fb1735df4 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Tue, 10 Nov 2020 02:40:53 +0000 Subject: [PATCH 1/2] CLN: use extract_array --- pandas/core/frame.py | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 049d2c4888a69..443eb2f8dd50a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -114,7 +114,6 @@ is_object_dtype, is_scalar, is_sequence, - needs_i8_conversion, pandas_dtype, ) from pandas.core.dtypes.missing import isna, notna @@ -6364,29 +6363,11 @@ def combine_first(self, other: DataFrame) -> DataFrame: """ import pandas.core.computation.expressions as expressions - def extract_values(arr): - # Does two things: - # 1. maybe gets the values from the Series / Index - # 2. convert datelike to i8 - # TODO: extract_array? - if isinstance(arr, (Index, Series)): - arr = arr._values - - if needs_i8_conversion(arr.dtype): - if is_extension_array_dtype(arr.dtype): - arr = arr.asi8 - else: - arr = arr.view("i8") - return arr - def combiner(x, y): - mask = isna(x) - # TODO: extract_array? - if isinstance(mask, (Index, Series)): - mask = mask._values + mask = extract_array(isna(x)) - x_values = extract_values(x) - y_values = extract_values(y) + x_values = extract_array(x) + y_values = extract_array(y) # If the column y in other DataFrame is not in first DataFrame, # just return y_values. From 63a54a0403a41cf4207af0574394a3b514244876 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Tue, 10 Nov 2020 04:17:50 +0000 Subject: [PATCH 2/2] CLN (feedback): pass extract_numpy kwarg to extract_array --- pandas/core/frame.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index d3d8253261fc3..4fa0b59808a52 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6371,8 +6371,8 @@ def combine_first(self, other: DataFrame) -> DataFrame: def combiner(x, y): mask = extract_array(isna(x)) - x_values = extract_array(x) - y_values = extract_array(y) + x_values = extract_array(x, extract_numpy=True) + y_values = extract_array(y, extract_numpy=True) # If the column y in other DataFrame is not in first DataFrame, # just return y_values.