@@ -1723,15 +1723,13 @@ def test_no_flex(self, f):
1723
1723
1724
1724
# DataFrame methods (which do not call _flex_binary_moment())
1725
1725
1726
- with warnings .catch_warnings (record = True ):
1727
-
1728
- results = [f (df ) for df in self .df1s ]
1729
- for (df , result ) in zip (self .df1s , results ):
1730
- tm .assert_index_equal (result .index , df .columns )
1731
- tm .assert_index_equal (result .columns , df .columns )
1732
- for i , result in enumerate (results ):
1733
- if i > 0 :
1734
- self .compare (result , results [0 ])
1726
+ results = [f (df ) for df in self .df1s ]
1727
+ for (df , result ) in zip (self .df1s , results ):
1728
+ tm .assert_index_equal (result .index , df .columns )
1729
+ tm .assert_index_equal (result .columns , df .columns )
1730
+ for i , result in enumerate (results ):
1731
+ if i > 0 :
1732
+ self .compare (result , results [0 ])
1735
1733
1736
1734
@pytest .mark .parametrize (
1737
1735
'f' , [lambda x : x .expanding ().cov (pairwise = True ),
@@ -1805,24 +1803,24 @@ def test_pairwise_with_other(self, f):
1805
1803
lambda x , y : x .ewm (com = 3 ).corr (y , pairwise = False ), ])
1806
1804
def test_no_pairwise_with_other (self , f ):
1807
1805
1808
- with warnings . catch_warnings ( record = True ):
1809
-
1810
- # DataFrame with another DataFrame, pairwise=False
1811
- results = [ f (df , self . df2 ) if df . columns . is_unique else None
1812
- for df in self . df1s ]
1813
- for ( df , result ) in zip ( self . df1s , results ):
1814
- if result is not None :
1806
+ # DataFrame with another DataFrame, pairwise=False
1807
+ results = [ f ( df , self . df2 ) if df . columns . is_unique else None
1808
+ for df in self . df1s ]
1809
+ for (df , result ) in zip ( self . df1s , results ):
1810
+ if result is not None :
1811
+ with catch_warnings ( record = True ):
1812
+ # we can have int and str columns
1815
1813
expected_index = df .index .union (self .df2 .index )
1816
1814
expected_columns = df .columns .union (self .df2 .columns )
1817
- tm .assert_index_equal (result .index , expected_index )
1818
- tm .assert_index_equal (result .columns , expected_columns )
1819
- else :
1820
- tm .assertRaisesRegexp (
1821
- ValueError , "'arg1' columns are not unique" , f , df ,
1822
- self .df2 )
1823
- tm .assertRaisesRegexp (
1824
- ValueError , "'arg2' columns are not unique" , f ,
1825
- self .df2 , df )
1815
+ tm .assert_index_equal (result .index , expected_index )
1816
+ tm .assert_index_equal (result .columns , expected_columns )
1817
+ else :
1818
+ tm .assertRaisesRegexp (
1819
+ ValueError , "'arg1' columns are not unique" , f , df ,
1820
+ self .df2 )
1821
+ tm .assertRaisesRegexp (
1822
+ ValueError , "'arg2' columns are not unique" , f ,
1823
+ self .df2 , df )
1826
1824
1827
1825
@pytest .mark .parametrize (
1828
1826
'f' , [lambda x , y : x .expanding ().cov (y ),
@@ -2664,7 +2662,7 @@ def test_rolling_functions_window_non_shrinkage_binary(self):
2664
2662
columns = Index (['A' , 'B' ], name = 'foo' ),
2665
2663
index = Index (range (4 ), name = 'bar' ))
2666
2664
df_expected = DataFrame (
2667
- columns = Index (['A' , 'B' ]),
2665
+ columns = Index (['A' , 'B' ], name = 'foo' ),
2668
2666
index = pd .MultiIndex .from_product ([df .index , df .columns ],
2669
2667
names = ['bar' , 'foo' ]),
2670
2668
dtype = 'float64' )
0 commit comments