@@ -5141,22 +5141,14 @@ def combine(self, other, func, fill_value=None, overwrite=True):
5141
5141
if not is_dtype_equal (other_dtype , new_dtype ):
5142
5142
otherSeries = otherSeries .astype (new_dtype )
5143
5143
5144
- # see if we need to be represented as i8 (datetimelike)
5145
- # try to keep us at this dtype
5146
- needs_i8_conversion_i = needs_i8_conversion (new_dtype )
5147
- if needs_i8_conversion_i :
5148
- arr = func (series , otherSeries , True )
5149
- else :
5150
- arr = func (series , otherSeries )
5151
-
5144
+ arr = func (series , otherSeries )
5152
5145
arr = maybe_downcast_to_dtype (arr , this_dtype )
5153
5146
5154
5147
result [col ] = arr
5155
5148
5156
5149
# convert_objects just in case
5157
5150
return self ._constructor (result , index = new_index ,
5158
- columns = new_columns )._convert (datetime = True ,
5159
- copy = False )
5151
+ columns = new_columns )
5160
5152
5161
5153
def combine_first (self , other ):
5162
5154
"""
@@ -5203,15 +5195,28 @@ def combine_first(self, other):
5203
5195
"""
5204
5196
import pandas .core .computation .expressions as expressions
5205
5197
5206
- def combiner (x , y , needs_i8_conversion = False ):
5207
- x_values = x .values if hasattr (x , 'values' ) else x
5208
- y_values = y .values if hasattr (y , 'values' ) else y
5209
- if needs_i8_conversion :
5210
- mask = isna (x )
5211
- x_values = x_values .view ('i8' )
5212
- y_values = y_values .view ('i8' )
5213
- else :
5214
- mask = isna (x_values )
5198
+ def extract_values (arr ):
5199
+ # Does two things:
5200
+ # 1. maybe gets the values from the Series / Index
5201
+ # 2. convert datelike to i8
5202
+ if isinstance (arr , (ABCIndexClass , ABCSeries )):
5203
+ arr = arr ._values
5204
+
5205
+ if needs_i8_conversion (arr ):
5206
+ # TODO(DatetimelikeArray): just use .asi8
5207
+ if is_extension_array_dtype (arr .dtype ):
5208
+ arr = arr .asi8
5209
+ else :
5210
+ arr = arr .view ('i8' )
5211
+ return arr
5212
+
5213
+ def combiner (x , y ):
5214
+ mask = isna (x )
5215
+ if isinstance (mask , (ABCIndexClass , ABCSeries )):
5216
+ mask = mask ._values
5217
+
5218
+ x_values = extract_values (x )
5219
+ y_values = extract_values (y )
5215
5220
5216
5221
# If the column y in other DataFrame is not in first DataFrame,
5217
5222
# just return y_values.
0 commit comments