This is my dataframe:
In [2]: fruits = pd.DataFrame({"apple_price": [100, 100, 200, 500, 100, 600, 200],
...: "cherry_price": [2, 3, 1, 0, 2, 1, 1],
...: "banana_price": [2, 4, 5, 2, 3, 5, 3],
...: "prices": ["apple_price", "apple_price", "cherry_price", "banana_price", "cherry_price",
...: "banana_price", "apple_price"],
...: "price_fruits": [100, 100, 100, 2, 3, 5, 200]})
In [3]: fruits
Out[3]:
apple_price cherry_price banana_price prices price_fruits
0 100 2 2 apple_price 100
1 100 3 4 apple_price 100
2 200 1 5 cherry_price 100
3 500 0 2 banana_price 2
4 100 2 3 cherry_price 3
5 600 1 5 banana_price 5
6 200 1 3 apple_price 200
Basically the prices for apple ["apple_price"]
must be divided by 100 (as the prices in apple_price
are in cents instead of Euro) whereas the prices for the other fruits should remain unchanged.
So, this would be my expect output:
In [5]: fruits_ad
Out[5]:
apple_price cherry_price banana_price prices price_fruits pr_fruits_adjusted
0 100 2 2 apple_price 100 1
1 100 3 4 apple_price 100 1
2 200 1 5 cherry_price 100 1
3 500 0 2 banana_price 2 2
4 100 2 3 cherry_price 3 3
5 600 1 5 banana_price 5 5
6 200 1 3 apple_price 200 2