How to replace elements in a list using dictionary lookup

前端 未结 5 1442
你的背包
你的背包 2020-12-03 10:37

Given this list

my_lst = [\'LAC\', \'HOU\', \'03/03 06:11 PM\', \'2.13\', \'1.80\', \'03/03 03:42 PM\']

I want to change its 0th

5条回答
  •  醉话见心
    2020-12-03 11:29

    This is a one-line in pandas ....

    df['A'].replace(dict(zip(
            ['SERVICIOS', 'ECON?MICO', 'ECONOMICO', 'EN ESPECIE'],
            ['servicios', 'economico', 'economico', 'en especie'])
                           ),regex=True)
    

提交回复
热议问题