0

I want to appending an element to column array in Panda Dataframe
I have a dataframe and I added a column including empty array

import pandas as pd

df1 = pd.DataFrame({'a':[0,1,2], "b": [3, 4, 6]})

df1["c"] = [[]] * df1.shape[0]

Output

    a   b   c
0   0   3   []
1   1   4   []
2   2   6   []

Now I want to append an element to the array in column 'c'
This is what i have tried:

df1["c"][2].append(1)

Output:
    a   b    c
0   0   3   [1]
1   1   4   [1]
2   2   6   [1]

I was expecting:

    a   b    c
0   0   3   []
1   1   4   []
2   2   6   [1]

0 Answers0