-1

I have a situation where I need to create a new pandas column based on the comma separated values that are present in the corresponding using some matching of the phrases. For examples: My data frame looks like this :

ID             INFORMATION
1              HR, MGMT, Leadership, etc
2              Analytics, leader, role, etc
3              Telecom, leader, management, manager, etc
4              IT, leader, role, etc
5              Management, HR, Role, Leadership

I want a new pandas column that will give me the following basis the selection of the keywords from the information column. For example: if I search for HR in row 1, then the HR Skills should be returned. In row 5 if I search for HR and Management- HR Management Skills should be returned. The output should look like this :

ID      SkillSet
1       HR Skills
2       Analytics Skills
3       Telecom Skills
4       IT Skills
5       HR and Management Skills

The problem is more around doing an active keyword search or multiple keyword search. How should I achieve this?

Django0602
  • 797
  • 7
  • 26
  • 1
    @ansev: returned the same information comma separated. I need to group them by doing a keyword search so that I can see the right information as per my output. Its more like getting rid of all the other words – Django0602 Feb 17 '20 at 17:15

1 Answers1

0
 df.loc[df['INFORMATION'].str.contains('HR'), 'SkillSet'] = 'HR Skills'
Django0602
  • 797
  • 7
  • 26