0

I'm trying to modify unwanted part of a string in a DataFrame. E.g in column title_0, the value needs to be changed to "INC000000324540".

    title_0 
0   Your Group have a new ticket INC000000324540 please help our customer

The issue I had is the value isn't changed even after using string slice.

appended_df_INC['title_0'].str.slice(start=28, stop=44)
1

1 Answer 1

1

with that line you are not assigning the slice column to the original dataframe. The function returns the new column infact the notebook shows it. You have to assign the column to the original df, for example:

df = pd.DataFrame({"x": "LongStringNumber1", "LongStringNumber2"})
df["x"] = df["x"].str.slice(start=5, stop=10)
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.