[Solved] Removing last words in each row in pandas dataframe


We can try using str.replace here:

df["first_middle_name"] = df["full_name"].replace("\s+\S+$", "")

See the above regex replacement working in the demo link below.

Demo

solved Removing last words in each row in pandas dataframe