Sum and Product
To calculate the total sum and product you can use the .sum()
and .prod()
methods, respectively. These methods can be applied to an entire DataFrame; in that case, the corresponding operation will be performed for each column. For instance, we can calculate the total price of all cars manufactured in 2010.
1234567# Importing library import pandas as pd # Reading csv file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/67798cef-5e7c-4fbc-af7d-ae96b4443c0a/audi.csv') # Total price of 2010 cars print(df.loc[df.year == 2010, 'price'].sum())
Дякуємо за ваш відгук!
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Запитайте мені питання про цей предмет
Сумаризуйте цей розділ
Покажіть реальні приклади
Awesome!
Completion rate improved to 3.33
Sum and Product
Свайпніть щоб показати меню
To calculate the total sum and product you can use the .sum()
and .prod()
methods, respectively. These methods can be applied to an entire DataFrame; in that case, the corresponding operation will be performed for each column. For instance, we can calculate the total price of all cars manufactured in 2010.
1234567# Importing library import pandas as pd # Reading csv file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/67798cef-5e7c-4fbc-af7d-ae96b4443c0a/audi.csv') # Total price of 2010 cars print(df.loc[df.year == 2010, 'price'].sum())
Дякуємо за ваш відгук!