How to calculate the sums of columns and rows of a pandas DataFrame in the Python programming language. More details: https://statisticsglobe.com/sum-of-co...
Python code of this video:
import pandas as pd # Load pandas
data = pd.DataFrame({'x1':[6, 2, 7, 1, 9, 3, 4, 9], # Create example DataFrame
'x2':[2, 5, 7, 1, 3, 1, 2, 3],
'x3':range(8, 0, - 1)})
print(data) # Print example DataFrame
print(data.sum()) # Get column sums
x1 41
x2 24
x3 36
dtype: int64
print(data.sum(axis = 1)) # Get row sums
0 16
1 14
2 20
3 7
4 16
5 7
6 8
7 13
dtype: int64
Follow me on Social Media:
Facebook – Statistics Globe Page: / statisticsglobecom
Facebook – R Programming Group for Discussions & Questions: / statisticsglobe
Facebook – Python Programming Group for Discussions & Questions: / statisticsglobepython
LinkedIn – Statistics Globe Page: / statisticsglobe
LinkedIn – R Programming Group for Discussions & Questions: / 12555223
LinkedIn – Python Programming Group for Discussions & Questions: / 12673534
Twitter: / joachimschork
Music by bensound.com
On this page of the site you can watch the video online Sum of Columns & Rows of pandas DataFrame in Python (Examples) | sum() Function | Each Column & Row with a duration of hours minute second in good quality, which was uploaded by the user Statistics Globe 07 December 2022, share the link with friends and acquaintances, this video has already been watched 758 times on youtube and it was liked by 6 viewers. Enjoy your viewing!