Finally, you can add a new column by performing a function on the existing columns.
Maybe we want to add a column to our inventory table with the amount of sales tax that we need to charge for each item. The following code multiplies each
0.075, the sales tax for our state:
df['Sales Tax'] = df.Price * 0.075
Now our table has a column called
|Product ID||Product Description||Cost to Manufacture||Price||Sales Tax|
|1||3 inch screw||0.50||0.75||0.06|
|2||2 inch nail||0.10||0.25||0.02|
Add a column to
'Margin', which is equal to the difference between the Price and the Cost to Manufacture.