-1

This is my dataset :

Datset example

I want to assign to the different values* such as 'W M I HOLDINGS CORP' and 'MILESTONE SCIENTIFIC INC' another variable in the column 'ticker' in order to have the opportunity to sort them. In the column 'ticker' I need to add WMIH and WLSS respectively to the two different values.

How can I do that ?

I am going to expect the output with something like this :

Output Example

  • I am little confused. `W M I HOLDINGS CORP` and `MILESTONE SCIENTIFIC INC` aren't variables, but values in one column, right? So you want to copy those values to the `ticker` column? – Matěj Račinský Mar 26 '19 at 11:44
  • I need to add the values 'WMIH' in correspondence of 'HOLDINGS CORP' and 'WLSS' in correspondence of 'MILESTONE SCIENTIFIC'. – jonny Bravo Mar 26 '19 at 11:50

1 Answers1

0

You should be ok with this. Assuming you have your dataset in df variable.

df.loc[df['comnam'] == 'W M I HOLDINGS CORP', 'ticker'] = 'WMIH'
df.loc[df['comnam'] == 'MILESTONE SCIENTIFIC INC', 'ticker'] = 'WLSS'
Matěj Račinský
  • 1,679
  • 1
  • 16
  • 28