0

my dataframe look like this:

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

expected dataframe:

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

1 Answer 1

2

You can just do

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

You have the same issue like before, list is not list

df.loc[df['variations_list2']=='[]','variations_list2'] = df['variations_list1']
Sign up to request clarification or add additional context in comments.

5 Comments

it's filling all row of 'variations_list2' but I need to fill only empty list row.["Burger","pizza"] have value ["$25","$30"] so I don't need to replace value of ["$25","$30"]
@boyenec check update
tried but still now same result. it's replacing all value even those are not empty list
@boyenec it work from my side , you may need to check your column type
I checked column type and it's object

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.