How to append the numpy lists of lists directly as columns to an existing CSV file?

Viewed 41

Suppose I have a variable value:

value = [array([   3,    0,     1, -9999]),
         array([   1,    8,     5, -9999])]

How to write these values as separate columns D, E, F and Gin pandas existing dataframe data. where data is

   A   B   C
0  2   6   1 
1  9   2   7

Expected Output:

    A   B  C  D  E  F  G
0   2   6  1  3  0  1  -9999
1   9   2  7  1  8  5  -9999
1 Answers

Apparently this works, who knew it was that simple!

df[['D', 'E', 'F']] = pd.DataFrame(value, index=df.index)
df        

   A  B  C  D  E  F
0  2  6  1  3  0  1
1  9  2  7  1  8  5
Related