Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### 1 np.where
- lcoe['MEWC'] =\
- np.where((lcoe['country']=='NG') &\
- (lcoe['sector'].isin([17, 18, 19, 20])),\
- lcoe['MEWC'] / 10 ** 3, lcoe['MEWC'])
- ### 2 define select
- select = (lcoe['country']=='NG') &\
- (lcoe['sector'].isin([17, 18, 19, 20]))
- lcoe.loc[select, 'MEWC'] =\
- lcoe[select].apply(lambda x: x['MEWC'] / 10 ** 3)
- ### 3 copy, modify, update
- temp = lcoe[(lcoe['country']=='NG') &\
- (lcoe['sector'].isin([17, 18, 19, 20]))].copy()
- temp = temp.assign(MEWC = lambda x: x['MEWC'] / 10 ** 3)
- lcoe = lcoe.update(temp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement