Skip to content

Commit e480a44

Browse files
authored
REF: use extract_array in DataFrame.combine_first (#37731)
1 parent a3d6ad8 commit e480a44

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

pandas/core/frame.py

+3-22
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
is_object_dtype,
115115
is_scalar,
116116
is_sequence,
117-
needs_i8_conversion,
118117
pandas_dtype,
119118
)
120119
from pandas.core.dtypes.missing import isna, notna
@@ -6374,29 +6373,11 @@ def combine_first(self, other: DataFrame) -> DataFrame:
63746373
"""
63756374
import pandas.core.computation.expressions as expressions
63766375

6377-
def extract_values(arr):
6378-
# Does two things:
6379-
# 1. maybe gets the values from the Series / Index
6380-
# 2. convert datelike to i8
6381-
# TODO: extract_array?
6382-
if isinstance(arr, (Index, Series)):
6383-
arr = arr._values
6384-
6385-
if needs_i8_conversion(arr.dtype):
6386-
if is_extension_array_dtype(arr.dtype):
6387-
arr = arr.asi8
6388-
else:
6389-
arr = arr.view("i8")
6390-
return arr
6391-
63926376
def combiner(x, y):
6393-
mask = isna(x)
6394-
# TODO: extract_array?
6395-
if isinstance(mask, (Index, Series)):
6396-
mask = mask._values
6377+
mask = extract_array(isna(x))
63976378

6398-
x_values = extract_values(x)
6399-
y_values = extract_values(y)
6379+
x_values = extract_array(x, extract_numpy=True)
6380+
y_values = extract_array(y, extract_numpy=True)
64006381

64016382
# If the column y in other DataFrame is not in first DataFrame,
64026383
# just return y_values.

0 commit comments

Comments
 (0)