I have a large three-column dataframe of this form:
Ref Colourref Shaperef
5 red 12 square 15
9 14 blue (circle14,2)
10 6 orange 12 18 square
12 pink1,7 [oval] [40]
14 [green] (rectsq#12,6)
...
And a long list with entries like this:
li = [
'oval 60 [oval] [40]',
'(circle14,2) circ',
'square 20',
'126 18 square 921#',
]
I want to replace the entries in the Shaperef column of the df with a value from the list if the full Shaperef string matches any part of any list item. If there is no match, the entry is not changed.
Desired output:
Ref Colourref Shaperef
5 red 12 square 15
9 14 blue (circle14,2) circ
10 6 orange 12 126 18 square 921#
12 pink1,7 oval 60 [oval] [40]
14 [green] (rectsq#12,6)
...
So refs 9, 10, 12 are updated as there is a partial match with a list item. Refs 5, 14 stay as there are.