I have a list of colors like this:
color = ['green', 'blue', 'red']
I have a Dataframe like this:
df:
col1 col2
A dark green
B sea blue
C blue
D exclusive red
E green
F pale red
I want to match col2
with the color
list. If any word of col2
matches the element of the color
list, replace it with the lists value.
The result data frame will be
col1 col2
A green
B blue
C blue
D red
E green
F red
What is the most efficient way to do it using pandas?