@@ -408,26 +408,16 @@ def xs(self, key, axis=0, copy=False):
408
408
# Arithmetic-related methods
409
409
410
410
def _combine_frame (self , other , func , fill_value = None , level = None ):
411
- new_index = self .index .union (other .index )
412
- new_columns = self .columns .union (other .columns )
411
+ this , other = self .align (other , join = 'outer' , level = level ,
412
+ copy = False )
413
+ new_index , new_columns = this .index , this .columns
413
414
414
415
if fill_value is not None or level is not None :
415
416
raise NotImplementedError
416
417
417
- this = self
418
- if self .index is not new_index :
419
- this = self .reindex (new_index )
420
- other = other .reindex (new_index )
421
-
422
418
if not self and not other :
423
419
return SparseDataFrame (index = new_index )
424
420
425
- if not other :
426
- return self * nan
427
-
428
- if not self :
429
- return other * nan
430
-
431
421
new_data = {}
432
422
for col in new_columns :
433
423
if col in this and col in other :
@@ -535,7 +525,10 @@ def _reindex_with_indexers(self, index, row_indexer, columns, col_indexer,
535
525
for col in columns :
536
526
if col not in self :
537
527
continue
538
- new_arrays [col ] = com .take_1d (self [col ].values , row_indexer )
528
+ if row_indexer is not None :
529
+ new_arrays [col ] = com .take_1d (self [col ].values , row_indexer )
530
+ else :
531
+ new_arrays [col ] = self [col ]
539
532
540
533
return self ._constructor (new_arrays , index = index , columns = columns )
541
534
0 commit comments