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
Смотрите видео Sum of Columns & Rows of pandas DataFrame in Python (Examples) | sum() Function | Each Column & Row онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Statistics Globe 07 Декабрь 2022. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 758 раз и оно понравилось 6 посетителям.