Pandas DataFrame scenarios to update in-place when using .replace() with regex
I've searched everywhere and can't find a clear answer. I'm relatively new to this, so bear with me. I'm working on a project and hit a roadblock. I am trying to replace specific substrings in a Pandas DataFrame column using the `.replace()` method with the `regex` option, but the changes don't seem to be taking effect. I am using Pandas version 1.3.3. Here is the code I have: ```python import pandas as pd data = {'text_column': ['apple', 'banana', 'apple pie', 'orange']} df = pd.DataFrame(data) # I want to replace 'apple' with 'fruit' df['text_column'].replace(to_replace='apple', value='fruit', regex=True, inplace=True) print(df) ``` I expected the output to show 'fruit' instead of 'apple' in the `text_column`, but it remains unchanged. The output I receive is: ``` text_column 0 apple 1 banana 2 apple pie 3 orange ``` I have tried removing `inplace=True` and assigning the result back to the DataFrame like this: ```python df['text_column'] = df['text_column'].replace(to_replace='apple', value='fruit', regex=True) ``` This way, I get the expected output: ``` text_column 0 fruit 1 banana 2 fruit pie 3 orange ``` However, I want to understand why using `inplace=True` didn't work as expected. Is there something I'm missing in my usage or a known scenario with the `.replace()` method in the version of Pandas I am using? Any insights or tips would be appreciated! This is part of a larger API I'm building. How would you solve this? My development environment is Ubuntu. What's the best practice here? For context: I'm using Python on macOS. Has anyone else encountered this?