Back

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

I have a DataFrame with numerical values. What is the simplest way of appending a row (with a given index value) that represents the sum of each column?

1 Answer

0 votes
by (108k points)

To add a row with column-totals, you can refer the following code:

df.loc['Total']= df.sum()

If you want to learn more about Pandas then visit this Python Course designed by the industrial experts.

Browse Categories

...