pandas 如何只替换空列表数据?

pandas how to replace only empty list data?

我的数据框是这样的:

   variations_list1          variations_list2
    ["yellow","ornage"]          []
    ["xl","xxl"]                 []
    ["Burger","pizza"]         ["",""]

预期数据帧:

 variations_list1          variations_list2
    ["yellow","ornage"]         ["yellow","ornage"] #filling emty list with current row data
    ["xl","xxl"]                ["xl","xxl"]
    ["Burger","pizza"]         ["",""]

你可以做到

df.loc[~df['variations_list2'].astype(bool),'variations_list2'] = df['variations_list1']

你和之前有同样的问题,列表不是列表

df.loc[df['variations_list2']=='[]','variations_list2'] = df['variations_list1']