Advertisement
Korotkodul

B. Сложная подкрутка_1

Apr 17th, 2025 (edited)
581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. def change_price(group):
  2.     mean = group['UnitPrice'].mean()
  3.     min_p = group['UnitPrice'].min()
  4.    
  5.     bad = group.assign(
  6.         UnitPrice=group['UnitPrice']*2,
  7.         Country=group['Country']+'_bad_times'
  8.     )
  9.     great = group.assign(
  10.         UnitPrice=np.maximum(min_p, group['UnitPrice']-0.15*mean),
  11.         Country=group['Country']+'_great_times'
  12.     )
  13.     return pd.concat([bad, great], ignore_index=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement