I've got the following df called "places"
place_name
0 "Palais et bâtiments officiels[modifier | modifier le code]"
1 "Lieux de culte renommés[modifier | modifier le code]"
2 "Vestiges gallo-romains[modifier | modifier le code]"
As you can see there is a similar substring [modifier | modifier le code] in all the inputs for places["place_name] and I would like to delete the substring.
I tried the following two techniques
places["place_name"] = places["place_name"].apply(lambda x: re.sub("\\[modifier \\| modifier le code\\]", "", x))
places["places_name"] = places["place_name"].str.replace("[modifier | modifier le code]", "", regex=False)
None of these work because I think the problem is that the substring I am trying to delete is stuck with another substring (note that there is no space at beginning) so I think the code does not recognise it as a string in itself. I have been trying to split this using split() method but I have the same issue since there is no space at the beginning of the string I am trying to delete.
Final output should be
place_name
0 "Palais et bâtiments officiels"
1 "Lieux de culte renommés"
2 "Vestiges gallo-romains"
I have tried to look for other solutions but can't find any, I know there are lot of questions with strings but can't find specific solution for this.