@@ -347,7 +347,7 @@ def __init__(self, data=None, index=None, columns=None, dtype=None,
347
347
elif isinstance (data , (np .ndarray , Series , Index )):
348
348
if data .dtype .names :
349
349
data_columns = list (data .dtype .names )
350
- data = dict (( k , data [k ]) for k in data_columns )
350
+ data = { k : data [k ] for k in data_columns }
351
351
if columns is None :
352
352
columns = data_columns
353
353
mgr = self ._init_dict (data , index , columns , dtype = dtype )
@@ -417,8 +417,7 @@ def _init_dict(self, data, index, columns, dtype=None):
417
417
extract_index (list (data .values ()))
418
418
419
419
# prefilter if columns passed
420
- data = dict ((k , v ) for k , v in compat .iteritems (data )
421
- if k in columns )
420
+ data = {k : v for k , v in compat .iteritems (data ) if k in columns }
422
421
423
422
if index is None :
424
423
index = extract_index (list (data .values ()))
@@ -3895,7 +3894,7 @@ def f(col):
3895
3894
return self ._constructor_sliced (r , index = new_index ,
3896
3895
dtype = r .dtype )
3897
3896
3898
- result = dict (( col , f (col )) for col in this )
3897
+ result = { col : f (col ) for col in this }
3899
3898
3900
3899
# non-unique
3901
3900
else :
@@ -3906,7 +3905,7 @@ def f(i):
3906
3905
return self ._constructor_sliced (r , index = new_index ,
3907
3906
dtype = r .dtype )
3908
3907
3909
- result = dict (( i , f (i )) for i , col in enumerate (this .columns ))
3908
+ result = { i : f (i ) for i , col in enumerate (this .columns )}
3910
3909
result = self ._constructor (result , index = new_index , copy = False )
3911
3910
result .columns = new_columns
3912
3911
return result
@@ -3984,7 +3983,7 @@ def _compare_frame_evaluate(self, other, func, str_rep, try_cast=True):
3984
3983
if self .columns .is_unique :
3985
3984
3986
3985
def _compare (a , b ):
3987
- return dict (( col , func (a [col ], b [col ])) for col in a .columns )
3986
+ return { col : func (a [col ], b [col ]) for col in a .columns }
3988
3987
3989
3988
new_data = expressions .evaluate (_compare , str_rep , self , other )
3990
3989
return self ._constructor (data = new_data , index = self .index ,
@@ -3993,8 +3992,8 @@ def _compare(a, b):
3993
3992
else :
3994
3993
3995
3994
def _compare (a , b ):
3996
- return dict (( i , func (a .iloc [:, i ], b .iloc [:, i ]) )
3997
- for i , col in enumerate (a .columns ))
3995
+ return { i : func (a .iloc [:, i ], b .iloc [:, i ])
3996
+ for i , col in enumerate (a .columns )}
3998
3997
3999
3998
new_data = expressions .evaluate (_compare , str_rep , self , other )
4000
3999
result = self ._constructor (data = new_data , index = self .index ,
0 commit comments