问题
I have been trying to figure this out all day. I am new to Python.
I have a table with about 50,000 records. But the table below will explain what I am trying to do.
I will like to add a third column called Category. This column will contain values based results from the conditions set on the Movies column.
-----------------------------------------
N | Movies
-----------------------------------------
1 | Save the Last Dance
-----------------------------------------
2 | Love and Other Drugs
---------------------------------------
3 | Dance with Me
---------------------------------------
4 | Love Actually
---------------------------------------
5 | High School Musical
----------------------------------------
The condition is this; search through the Movies column for these words {Dance, Love, and Musical). If the word is found in the string, return the word in the Category column.
This will produce a new dataframe like this at the end;
-----------------------------------------
N | Movies | Category
-----------------------------------------
1 | Save the Last Dance | Dance
-----------------------------------------
2 | Love and Other Drugs | Love
---------------------------------------
3 | Dance with Me | Dance
---------------------------------------
4 | Love Actually | Love
---------------------------------------
5 | High School Musical | Musical
----------------------------------------
Thanks in advance!!