@@ -2202,7 +2202,7 @@ def last(self, offset):
2202
2202
return self .ix [start :]
2203
2203
2204
2204
def align (self , other , join = 'outer' , axis = None , level = None , copy = True ,
2205
- fill_value = np . nan , method = None , limit = None , fill_axis = 0 ):
2205
+ fill_value = None , method = None , limit = None , fill_axis = 0 ):
2206
2206
"""
2207
2207
Align two object on their axes with the
2208
2208
specified join method for each axis Index
@@ -2288,35 +2288,51 @@ def _align_series(self, other, join='outer', axis=None, level=None,
2288
2288
fill_axis = 0 ):
2289
2289
from pandas import DataFrame
2290
2290
2291
- fdata = self ._data
2292
- if axis == 0 :
2293
- join_index = self .index
2294
- lidx , ridx = None , None
2295
- if not self .index .equals (other .index ):
2296
- join_index , lidx , ridx = self .index .join (other .index , how = join ,
2297
- return_indexers = True )
2291
+ # series/series compat
2292
+ if isinstance (self , ABCSeries ) and isinstance (other , ABCSeries ):
2293
+ if axis :
2294
+ raise ValueError ('cannot align series to a series other than axis 0' )
2298
2295
2299
- if lidx is not None :
2300
- fdata = fdata .reindex_indexer (join_index , lidx , axis = 1 )
2301
- elif axis == 1 :
2302
- join_index = self .columns
2303
- lidx , ridx = None , None
2304
- if not self .columns .equals (other .index ):
2305
- join_index , lidx , ridx = \
2306
- self .columns .join (other .index , how = join ,
2307
- return_indexers = True )
2296
+ join_index , lidx , ridx = self .index .join (other .index , how = join ,
2297
+ level = level ,
2298
+ return_indexers = True )
2299
+
2300
+ left_result = self ._reindex_indexer (join_index , lidx , copy )
2301
+ right_result = other ._reindex_indexer (join_index , ridx , copy )
2308
2302
2309
- if lidx is not None :
2310
- fdata = fdata .reindex_indexer (join_index , lidx , axis = 0 )
2311
2303
else :
2312
- raise ValueError ('Must specify axis=0 or 1' )
2313
2304
2314
- if copy and fdata is self ._data :
2315
- fdata = fdata .copy ()
2305
+ # one has > 1 ndim
2306
+ fdata = self ._data
2307
+ if axis == 0 :
2308
+ join_index = self .index
2309
+ lidx , ridx = None , None
2310
+ if not self .index .equals (other .index ):
2311
+ join_index , lidx , ridx = self .index .join (other .index , how = join ,
2312
+ return_indexers = True )
2313
+
2314
+ if lidx is not None :
2315
+ fdata = fdata .reindex_indexer (join_index , lidx , axis = 1 )
2316
+ elif axis == 1 :
2317
+ join_index = self .columns
2318
+ lidx , ridx = None , None
2319
+ if not self .columns .equals (other .index ):
2320
+ join_index , lidx , ridx = \
2321
+ self .columns .join (other .index , how = join ,
2322
+ return_indexers = True )
2323
+
2324
+ if lidx is not None :
2325
+ fdata = fdata .reindex_indexer (join_index , lidx , axis = 0 )
2326
+ else :
2327
+ raise ValueError ('Must specify axis=0 or 1' )
2328
+
2329
+ if copy and fdata is self ._data :
2330
+ fdata = fdata .copy ()
2316
2331
2317
- left_result = DataFrame (fdata )
2318
- right_result = other if ridx is None else other .reindex (join_index )
2332
+ left_result = DataFrame (fdata )
2333
+ right_result = other if ridx is None else other .reindex (join_index )
2319
2334
2335
+ # fill
2320
2336
fill_na = notnull (fill_value ) or (method is not None )
2321
2337
if fill_na :
2322
2338
return (left_result .fillna (fill_value , method = method , limit = limit ,
0 commit comments