Sum of Columns & Rows of pandas DataFrame in Python (Examples) | sum() Function | Each Column & Row

Veröffentlicht am: 07 Dezember 2022
auf dem Kanal: Statistics Globe
758
6

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


Auf dieser Seite können Sie das Online-Video Sum of Columns & Rows of pandas DataFrame in Python (Examples) | sum() Function | Each Column & Row mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Statistics Globe 07 Dezember 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 758 Mal angesehen und es wurde von 6 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!