1

I have a multi step task. I have a csv file which contains two columns: color_shades and primary_colors Color_shades column contains names of colors shades and primary_colors column which is empty and should be filled by primary color names corresponding to color shades. Several color shades can be linked to one primary color. For example for yellow color (primary_color) can be linked several following color shades: amber, mustard, banana etc. For example

|color_shades|primary_colors|
|------------|--------------|
|amber       |              |
|mustard     |              |
|banana      |              |
  

I have an idea to create a dictionary where keys will be the primary color names and values are list of its color shades names. Then take from dictionary one name of color_shade from dict values then run pandas str.contain() function on color_shades column to find matched color shades than after finding it fill in primary_color column primary color name corresponding to found color shade from dictionary key. For example

dict={'yellow' =['amber','mustard', 'banana']}

How to complete this task ? Can anyone reffer me to code examples to do it

I expect that anyone will help me with referring on code functions to complete this task

0 Answers0