Unlock the Potential of Open AI in Smart Manufacturing # Calculate the profit margin for each scenario by dividing the profit by the revenue df [' profit _ margin '] = df [' profit '] / df [' revenue ']
# Return the DataFrame with the new columns return df
# Example import pandas as pd
# Create a sample DataFrame with some data
df = pd . DataFrame ({' scenario ': [' A ', ' B ', ' C ', ' D '], ' demand ': [ 1000 , 800 , 1200 , 1500 ], ' price ': [ 10 , 12 , 8 , 9 ], ' cost ': [ 5000 , 6000 , 4000 , 4500 ]})
# Call the function to simulate the performance df = simulate _ performance ( df )
# Print the result print ( df )
# Output scenario demand price cost revenue profit profit _ margin
0 |
A |
1000 |
10 5000 |
10000 |
5000 |
0.500000 |
1 |
B |
800 |
12 6000 |
9600 |
3600 |
0.375000 |
2 |
C |
1200 |
8 4000 |
9600 |
5600 |
0.583333 |
3 |
D |
1500 |
9 4500 |
13500 |
9000 |
0.666667 |
56 March 2024