11
11
12
12
import pandas as pd
13
13
from pandas import DataFrame , Index , Series , Timestamp , date_range
14
- from pandas .tests .frame .common import TestData
15
14
import pandas .util .testing as tm
16
15
from pandas .util .testing import assert_frame_equal , assert_series_equal
17
16
18
17
19
- class TestDataFrameConcatCommon (TestData ):
18
+ class TestDataFrameConcatCommon ():
20
19
21
20
def test_concat_multiple_frames_dtypes (self ):
22
21
@@ -515,7 +514,7 @@ def test_concat_astype_dup_col(self):
515
514
tm .assert_frame_equal (result , expected )
516
515
517
516
518
- class TestDataFrameCombineFirst (TestData ):
517
+ class TestDataFrameCombineFirst ():
519
518
520
519
def test_combine_first_mixed (self ):
521
520
a = Series (['a' , 'b' ], index = lrange (2 ))
@@ -531,22 +530,22 @@ def test_combine_first_mixed(self):
531
530
combined = f .combine_first (g )
532
531
tm .assert_frame_equal (combined , exp )
533
532
534
- def test_combine_first (self ):
533
+ def test_combine_first (self , float_frame ):
535
534
# disjoint
536
- head , tail = self . frame [:5 ], self . frame [5 :]
535
+ head , tail = float_frame [:5 ], float_frame [5 :]
537
536
538
537
combined = head .combine_first (tail )
539
- reordered_frame = self . frame .reindex (combined .index )
538
+ reordered_frame = float_frame .reindex (combined .index )
540
539
assert_frame_equal (combined , reordered_frame )
541
- assert tm .equalContents (combined .columns , self . frame .columns )
540
+ assert tm .equalContents (combined .columns , float_frame .columns )
542
541
assert_series_equal (combined ['A' ], reordered_frame ['A' ])
543
542
544
543
# same index
545
- fcopy = self . frame .copy ()
544
+ fcopy = float_frame .copy ()
546
545
fcopy ['A' ] = 1
547
546
del fcopy ['C' ]
548
547
549
- fcopy2 = self . frame .copy ()
548
+ fcopy2 = float_frame .copy ()
550
549
fcopy2 ['B' ] = 0
551
550
del fcopy2 ['D' ]
552
551
@@ -570,20 +569,20 @@ def test_combine_first(self):
570
569
assert (combined ['A' ][:10 ] == 0 ).all ()
571
570
572
571
# no overlap
573
- f = self . frame [:10 ]
574
- g = self . frame [10 :]
572
+ f = float_frame [:10 ]
573
+ g = float_frame [10 :]
575
574
combined = f .combine_first (g )
576
575
assert_series_equal (combined ['A' ].reindex (f .index ), f ['A' ])
577
576
assert_series_equal (combined ['A' ].reindex (g .index ), g ['A' ])
578
577
579
578
# corner cases
580
- comb = self . frame . combine_first (self . empty )
581
- assert_frame_equal (comb , self . frame )
579
+ comb = float_frame . combine_first (DataFrame ({}) )
580
+ assert_frame_equal (comb , float_frame )
582
581
583
- comb = self . empty . combine_first (self . frame )
584
- assert_frame_equal (comb , self . frame )
582
+ comb = DataFrame ({}). combine_first (float_frame )
583
+ assert_frame_equal (comb , float_frame )
585
584
586
- comb = self . frame .combine_first (DataFrame (index = ["faz" , "boo" ]))
585
+ comb = float_frame .combine_first (DataFrame (index = ["faz" , "boo" ]))
587
586
assert "faz" in comb .index
588
587
589
588
# #2525
@@ -850,7 +849,7 @@ def test_concat_datetime_datetime64_frame(self):
850
849
pd .concat ([df1 , df2_obj ])
851
850
852
851
853
- class TestDataFrameUpdate (TestData ):
852
+ class TestDataFrameUpdate ():
854
853
855
854
def test_update_nan (self ):
856
855
# #15593 #15617
0 commit comments