1

I have a column in a dataframe size:

   size
  --------
    big
    normal
    small

I want to mal the values like this:

big == 1
normal == -1
small == 0

I can run apply(lambda x: 1 if x=='big' else -1) but I dont know to use it with 3 values.

Can someone help me please?

Katty_one
  • 351
  • 1
  • 8

1 Answers1

0

Try something like

apply(lambda x: {'big': 1, 'normal': -1, 'small': 0}[x])
tkupari
  • 31
  • 4