Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def change_price(group):
- mean = group['UnitPrice'].mean()
- min_p = group['UnitPrice'].min()
- bad = group.assign(
- UnitPrice=group['UnitPrice']*2,
- Country=group['Country']+'_bad_times'
- )
- great = group.assign(
- UnitPrice=np.maximum(min_p, group['UnitPrice']-0.15*mean),
- Country=group['Country']+'_great_times'
- )
- return pd.concat([bad, great], ignore_index=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement