@@ -2848,28 +2848,34 @@ def _combine_const(self, other, func, raise_on_error=True):
2848
2848
new_data = self ._data .eval (func , other , raise_on_error = raise_on_error )
2849
2849
return self ._constructor (new_data )
2850
2850
2851
+
2852
+ def _compare_frame_evaluate (self , other , func , str_rep ):
2853
+
2854
+ # unique
2855
+ if self .columns .is_unique :
2856
+ def _compare (a , b ):
2857
+ return dict ([(col , func (a [col ], b [col ])) for col in a .columns ])
2858
+ new_data = expressions .evaluate (_compare , str_rep , self , other )
2859
+ return self ._constructor (data = new_data , index = self .index ,
2860
+ columns = self .columns , copy = False )
2861
+ # non-unique
2862
+ else :
2863
+ def _compare (a , b ):
2864
+ return [func (a .iloc [:,i ], b .iloc [:,i ]) for i , col in enumerate (a .columns )]
2865
+ new_data = expressions .evaluate (_compare , str_rep , self , other )
2866
+ return self ._constructor (data = new_data , index = self .columns ,
2867
+ columns = self .index , copy = False ).T
2868
+
2851
2869
def _compare_frame (self , other , func , str_rep ):
2852
2870
if not self ._indexed_same (other ):
2853
2871
raise ValueError ('Can only compare identically-labeled '
2854
2872
'DataFrame objects' )
2855
-
2856
- def _compare (a , b ):
2857
- return dict ([(col , func (a [col ], b [col ])) for col in a .columns ])
2858
- new_data = expressions .evaluate (_compare , str_rep , self , other )
2859
-
2860
- return self ._constructor (data = new_data , index = self .index ,
2861
- columns = self .columns , copy = False )
2873
+ return self ._compare_frame_evaluate (other , func , str_rep )
2862
2874
2863
2875
def _flex_compare_frame (self , other , func , str_rep , level ):
2864
2876
if not self ._indexed_same (other ):
2865
2877
self , other = self .align (other , 'outer' , level = level )
2866
-
2867
- def _compare (a , b ):
2868
- return dict ([(col , func (a [col ], b [col ])) for col in a .columns ])
2869
- new_data = expressions .evaluate (_compare , str_rep , self , other )
2870
-
2871
- return self ._constructor (data = new_data , index = self .index ,
2872
- columns = self .columns , copy = False )
2878
+ return self ._compare_frame_evaluate (other , func , str_rep )
2873
2879
2874
2880
def combine (self , other , func , fill_value = None , overwrite = True ):
2875
2881
"""
@@ -3792,8 +3798,8 @@ def pretty_name(x):
3792
3798
3793
3799
destat = []
3794
3800
3795
- for column in numdata .columns :
3796
- series = self [ column ]
3801
+ for i in range ( len ( numdata .columns )) :
3802
+ series = numdata . iloc [:, i ]
3797
3803
destat .append ([series .count (), series .mean (), series .std (),
3798
3804
series .min (), series .quantile (lb ), series .median (),
3799
3805
series .quantile (ub ), series .max ()])
0 commit comments