Trying to clear wrong text that comes after the "Model" value in the "Name" column.
df = pd.DataFrame([['ABC-12(s)', 'Some text ABC-12(s) wrong text'], ['ABC-45', 'Other text ABC-45 garbage text'], ['XYZ-LL', 'Another text XYZ-LL unneeded text']], columns = ['Model', 'Name'])
| index | Model | Name |
|---|---|---|
| 0 | ABC-12(s) | Some text ABC-12(s) wrong text |
| 1 | ABC-45 | Other text ABC-45 garbage text |
| 2 | XYZ-LL | Another text XYZ-LL unneeded text |
Expected result:
| index | Model | Name |
|---|---|---|
| 0 | ABC-12(s) | Some text ABC-12(s) |
| 1 | ABC-45 | Other text ABC-45 |
| 2 | XYZ-LL | Another text XYZ-LL |
Have tried:
df["name"] = df["name"].str.partition(df["model"].to_string(), expand=False)
But that gives back the original string without changes or error. Like it could not find the delimiter within the "Name" cell. Seems like I'm missing something very simple.