How to remove the last 2 words in a dataframe; Pandas
Advertisements I am filtering my data and I want to remove the year and location (Islamabad, Lahore, etc) in the ‘Name’ column and I don’t know what to do This is the Picture >Solution : We can use str.replace here: df["Name"] = df["Name"].str.replace(r’\s+\d{4} \w+$’, ”, regex=True)