Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I have the single-column Dataframe similar to a example below:

import pandas

df = pandas.DataFrame({'Column': [[10, 100],[20, 200],[30, 300]]})

     Column

0 [10, 100]

1 [20, 200]

2 [30, 300]

How can I add a rows element by element such that my result will be:

     Column

0 [60, 600]

1 Answer

0 votes
by (36.8k points)

Assuming all your arrays have same size as in your sample data:

np.array(df['Column'].to_list()).sum(axis=0)

Output:

array([ 60, 600])

 Want to be a master in Data Science? Enroll in this Data Science Courses

Browse Categories

...