Advertisement
elena1234

arithmetic operations in dataframe in Python

Mar 22nd, 2023
586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. sales.Thu.mul(sales.perc_Bonus, fill_value=0)
  2. sales.iloc[:, :-1].sum(axis = 1).mul(sales.perc_Bonus)
  3. sales["Bonus"] = sales.iloc[:, :-1].sum(axis = 1).mul(sales.perc_Bonus)
  4.  
  5. titanic["no_relat"] = titanic.sibsp.add(titanic.parch)
  6. titanic["YoB"] = titanic.age.sub(1912).mul(-1)
  7.  
  8. fx_rate = 1.1
  9. titanic["EUR_fare"] = titanic.fare.div(fx_rate)
  10.  
  11. sales.iloc[:, :-2].sub(fixed_costs, fill_value = 0)
  12. sales.iloc[:, :-2].mul(perc_Bonus, fill_value = 0)
  13. sales.iloc[:, :-2].floordiv(lot_size, fill_value = 0).mul(bonus_per_lot).sum(axis = 1)
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement