0

enter image description here

sub4 = sub4.melt(id_vars = 'Sort_order','year'
                           ,var_name= 'sex'
                           ,value_name= "International_migrant_stock_at_mid-year")

I try to melt the dataframe to separate sex and migrant stock. I think my codes look fine but it just keeps giving me the syntax error. Does anyone know how to fix it?

I try to melt the dataframe to separate sex and migrant stock. I think my codes look fine but it just keeps giving me the syntax error. Does anyone know how to fix it?

1 Answers1

0

need [ ] for id_vars

sub4 = sub4.melt(
    id_vars=['Sort_order', 'year'], 
    var_name='sex',
    value_name="International_migrant_stock_at_mid-year"
)
Khai Kim
  • 66
  • 3