1
a = "Other (please specify) (What were you trying to do on the website when you encountered ^f('l1')^?Â\xa0)"

There are many values starting with '^f' and ending with '^' in a pandas column. And I need to replace them like below :

"Other (please specify) (What were you trying to do on the website when you encountered THIS ISSUE?Â\xa0)"
1
  • 1
    This is what you looking for? Commented Sep 19, 2021 at 8:35

1 Answer 1

3

You don't mention what you've tried already, nor what the rest of your DataFrame looks like but here is a minimal example:

# Create a DataFrame with a single data point
df = pd.DataFrame(["... encountered ^f('l1')^?Â\xa0)"])

# Define a regex pattern
pattern = r'(\^f.+\^)'

# Use the .replace() method to replace
df = df.replace(to_replace=pattern, value='TEST', regex=True)

Output

                          0
0  ... encountered TEST? )
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.