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)
CodePudding user response:
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)