Pandas DataFrame conditionally updating values with a custom function not applying as expected
I'm trying to figure out I'm testing a new approach and I'm prototyping a solution and I'm stuck on something that should probably be simple... I'm trying to apply a custom function to update values in my DataFrame based on specific conditions, but it seems like the function isn't modifying the values as expected. I'm using Pandas version 1.5.1. My goal is to increase the 'price' column by 10% for all rows where the 'category' is 'A'. Hereβs the simplified version of my DataFrame: ```python import pandas as pd data = { 'category': ['A', 'B', 'A', 'C'], 'price': [100, 200, 150, 300] } df = pd.DataFrame(data) ``` I defined my function like this: ```python def update_price(row): if row['category'] == 'A': return row['price'] * 1.1 return row['price'] ``` And then I applied it with: ```python df['price'] = df.apply(update_price, axis=1) ``` After running this, I expected to see the prices for category 'A' updated, but it appears that the values remain unchanged. When I print `df`, it still shows the original prices. I also tried using `np.where`, but I couldn't get that to work either. Am I missing something in how I'm applying the function, or is there a better way to achieve this? Any help would be appreciated! I'm working on a API that needs to handle this. What's the best practice here? This issue appeared after updating to Python 3.9. I'm open to any suggestions. I'm working on a application that needs to handle this. Is this even possible?