Skip to content
Advertisement

Sum values of a coulmn in specific rows in a dataframe

I would like to learn how to specify a “subset-sum” in a dataframe

My dataframe looks like this:

enter image description here

The Data/Time column is the dataframes’ index

With

JavaScript

I get the total sum of column A.

My aim is to sum up a subset of rows only like between 2022-03-18 07:37:51 and 2022-03-18 07:37:55

so that I get a “sum” row:

enter image description here

How can I specify the row numbers to be summed for each column, especially when the index is in datetime format?

Advertisement

Answer

JavaScript

simply, use axis = 0 for each coulmn sum, and check by a.index >= ‘2020-01-01 00:00:16’ and equivalent for upper bound

if you want to use datetime module:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement