@@ -392,27 +392,57 @@ def test_missing_axis_specification_exception(self):
392
392
with pytest .raises (ValueError , match = r"axis=0 or 1" ):
393
393
df .align (series )
394
394
395
- def _check_align (self , a , b , axis , fill_axis , how , method , limit = None ):
395
+ @pytest .mark .parametrize ("method" , ["pad" , "bfill" ])
396
+ @pytest .mark .parametrize ("axis" , [0 , 1 , None ])
397
+ @pytest .mark .parametrize ("fill_axis" , [0 , 1 ])
398
+ @pytest .mark .parametrize ("how" , ["inner" , "outer" , "left" , "right" ])
399
+ @pytest .mark .parametrize (
400
+ "left_slice" ,
401
+ [
402
+ [slice (4 ), slice (10 )],
403
+ [slice (0 ), slice (0 )],
404
+ ],
405
+ )
406
+ @pytest .mark .parametrize (
407
+ "right_slice" ,
408
+ [
409
+ [slice (2 , None ), slice (6 , None )],
410
+ [slice (0 ), slice (0 )],
411
+ ],
412
+ )
413
+ @pytest .mark .parametrize ("limit" , [1 , None ])
414
+ def test_align_fill_method (
415
+ self , how , method , axis , fill_axis , float_frame , left_slice , right_slice , limit
416
+ ):
417
+ frame = float_frame
418
+ left = frame .iloc [left_slice [0 ], left_slice [1 ]]
419
+ right = frame .iloc [right_slice [0 ], right_slice [1 ]]
420
+
396
421
msg = (
397
422
"The 'method', 'limit', and 'fill_axis' keywords in DataFrame.align "
398
423
"are deprecated"
399
424
)
400
425
401
426
with tm .assert_produces_warning (FutureWarning , match = msg ):
402
- aa , ab = a .align (
403
- b , axis = axis , join = how , method = method , limit = limit , fill_axis = fill_axis
427
+ aa , ab = left .align (
428
+ right ,
429
+ axis = axis ,
430
+ join = how ,
431
+ method = method ,
432
+ limit = limit ,
433
+ fill_axis = fill_axis ,
404
434
)
405
435
406
436
join_index , join_columns = None , None
407
437
408
- ea , eb = a , b
438
+ ea , eb = left , right
409
439
if axis is None or axis == 0 :
410
- join_index = a .index .join (b .index , how = how )
440
+ join_index = left .index .join (right .index , how = how )
411
441
ea = ea .reindex (index = join_index )
412
442
eb = eb .reindex (index = join_index )
413
443
414
444
if axis is None or axis == 1 :
415
- join_columns = a .columns .join (b .columns , how = how )
445
+ join_columns = left .columns .join (right .columns , how = how )
416
446
ea = ea .reindex (columns = join_columns )
417
447
eb = eb .reindex (columns = join_columns )
418
448
@@ -424,42 +454,6 @@ def _check_align(self, a, b, axis, fill_axis, how, method, limit=None):
424
454
tm .assert_frame_equal (aa , ea )
425
455
tm .assert_frame_equal (ab , eb )
426
456
427
- @pytest .mark .parametrize ("meth" , ["pad" , "bfill" ])
428
- @pytest .mark .parametrize ("ax" , [0 , 1 , None ])
429
- @pytest .mark .parametrize ("fax" , [0 , 1 ])
430
- @pytest .mark .parametrize ("how" , ["inner" , "outer" , "left" , "right" ])
431
- def test_align_fill_method (self , how , meth , ax , fax , float_frame ):
432
- df = float_frame
433
- self ._check_align_fill (df , how , meth , ax , fax )
434
-
435
- def _check_align_fill (self , frame , kind , meth , ax , fax ):
436
- left = frame .iloc [0 :4 , :10 ]
437
- right = frame .iloc [2 :, 6 :]
438
- empty = frame .iloc [:0 , :0 ]
439
-
440
- self ._check_align (left , right , axis = ax , fill_axis = fax , how = kind , method = meth )
441
- self ._check_align (
442
- left , right , axis = ax , fill_axis = fax , how = kind , method = meth , limit = 1
443
- )
444
-
445
- # empty left
446
- self ._check_align (empty , right , axis = ax , fill_axis = fax , how = kind , method = meth )
447
- self ._check_align (
448
- empty , right , axis = ax , fill_axis = fax , how = kind , method = meth , limit = 1
449
- )
450
-
451
- # empty right
452
- self ._check_align (left , empty , axis = ax , fill_axis = fax , how = kind , method = meth )
453
- self ._check_align (
454
- left , empty , axis = ax , fill_axis = fax , how = kind , method = meth , limit = 1
455
- )
456
-
457
- # both empty
458
- self ._check_align (empty , empty , axis = ax , fill_axis = fax , how = kind , method = meth )
459
- self ._check_align (
460
- empty , empty , axis = ax , fill_axis = fax , how = kind , method = meth , limit = 1
461
- )
462
-
463
457
def test_align_series_check_copy (self ):
464
458
# GH#
465
459
df = DataFrame ({0 : [1 , 2 ]})
0 commit comments