I have a dataframe which have lists or values in their columns; something like the following:
df
A B C D
0 [] [3] ['ON'] 5
1 'a' ['a'] ['ON'] 5
2 5 [3] ['ON'] 5
3 [] [3] ['ON'] 5
...
I would like to replace all the values inside columns A
, B
, and C
with empty lists. I tried using .assign(column_name='value')
seperatly for the columns A
, B
, and C
. I can set a value but I cannot set an empty list. I do not want to use .apply(lambda x: [])
, since it is rather slow.
Is there any other way?
Expected Outcome:
df
A B C D
0 [] [] [] 5
1 [] [] [] 5
2 [] [] [] 5
3 [] [] [] 5
...
what I basically need isa pandas function which can do: change everything in columns=['A','B','C'] to []