44import pytest
55
66from pandas import DataFrame , Index , period_range
7- from pandas .tests .frame .common import TestData
87import pandas .util .testing as tm
98
109
@@ -16,11 +15,6 @@ def frame_with_period_index():
1615 index = period_range (start = '2000' , freq = 'A' , periods = 4 ))
1716
1817
19- @pytest .fixture
20- def frame ():
21- return TestData ().frame
22-
23-
2418@pytest .fixture
2519def left ():
2620 return DataFrame ({'a' : [20 , 10 , 0 ]}, index = [2 , 1 , 0 ])
@@ -63,11 +57,11 @@ def test_join(left, right, how, sort, expected):
6357 tm .assert_frame_equal (result , expected )
6458
6559
66- def test_join_index (frame ):
60+ def test_join_index (float_frame ):
6761 # left / right
6862
69- f = frame .loc [frame .index [:10 ], ['A' , 'B' ]]
70- f2 = frame .loc [frame .index [5 :], ['C' , 'D' ]].iloc [::- 1 ]
63+ f = float_frame .loc [float_frame .index [:10 ], ['A' , 'B' ]]
64+ f2 = float_frame .loc [float_frame .index [5 :], ['C' , 'D' ]].iloc [::- 1 ]
7165
7266 joined = f .join (f2 )
7367 tm .assert_index_equal (f .index , joined .index )
@@ -91,7 +85,7 @@ def test_join_index(frame):
9185 # outer
9286
9387 joined = f .join (f2 , how = 'outer' )
94- tm .assert_index_equal (joined .index , frame .index .sort_values ())
88+ tm .assert_index_equal (joined .index , float_frame .index .sort_values ())
9589 tm .assert_index_equal (joined .columns , expected_columns )
9690
9791 with pytest .raises (ValueError , match = 'join method' ):
@@ -101,16 +95,16 @@ def test_join_index(frame):
10195 msg = 'columns overlap but no suffix'
10296 for how in ('outer' , 'left' , 'inner' ):
10397 with pytest .raises (ValueError , match = msg ):
104- frame .join (frame , how = how )
98+ float_frame .join (float_frame , how = how )
10599
106100
107- def test_join_index_more (frame ):
108- af = frame .loc [:, ['A' , 'B' ]]
109- bf = frame .loc [::2 , ['C' , 'D' ]]
101+ def test_join_index_more (float_frame ):
102+ af = float_frame .loc [:, ['A' , 'B' ]]
103+ bf = float_frame .loc [::2 , ['C' , 'D' ]]
110104
111105 expected = af .copy ()
112- expected ['C' ] = frame ['C' ][::2 ]
113- expected ['D' ] = frame ['D' ][::2 ]
106+ expected ['C' ] = float_frame ['C' ][::2 ]
107+ expected ['D' ] = float_frame ['D' ][::2 ]
114108
115109 result = af .join (bf )
116110 tm .assert_frame_equal (result , expected )
@@ -122,28 +116,28 @@ def test_join_index_more(frame):
122116 tm .assert_frame_equal (result , expected .loc [:, result .columns ])
123117
124118
125- def test_join_index_series (frame ):
126- df = frame .copy ()
127- s = df .pop (frame .columns [- 1 ])
119+ def test_join_index_series (float_frame ):
120+ df = float_frame .copy ()
121+ s = df .pop (float_frame .columns [- 1 ])
128122 joined = df .join (s )
129123
130124 # TODO should this check_names ?
131- tm .assert_frame_equal (joined , frame , check_names = False )
125+ tm .assert_frame_equal (joined , float_frame , check_names = False )
132126
133127 s .name = None
134128 with pytest .raises (ValueError , match = 'must have a name' ):
135129 df .join (s )
136130
137131
138- def test_join_overlap (frame ):
139- df1 = frame .loc [:, ['A' , 'B' , 'C' ]]
140- df2 = frame .loc [:, ['B' , 'C' , 'D' ]]
132+ def test_join_overlap (float_frame ):
133+ df1 = float_frame .loc [:, ['A' , 'B' , 'C' ]]
134+ df2 = float_frame .loc [:, ['B' , 'C' , 'D' ]]
141135
142136 joined = df1 .join (df2 , lsuffix = '_df1' , rsuffix = '_df2' )
143137 df1_suf = df1 .loc [:, ['B' , 'C' ]].add_suffix ('_df1' )
144138 df2_suf = df2 .loc [:, ['B' , 'C' ]].add_suffix ('_df2' )
145139
146- no_overlap = frame .loc [:, ['A' , 'D' ]]
140+ no_overlap = float_frame .loc [:, ['A' , 'D' ]]
147141 expected = df1_suf .join (df2_suf ).join (no_overlap )
148142
149143 # column order not necessarily sorted
0 commit comments