How to find the area below and above a point for a given time period using scipy?

时间:2018-09-18 19:32:57

标签: python pandas scipy

I have a pandas dataset with date being the index and a number in the value column. There is one year's worth of data.

How can I find find the area (integral) below and above each date's value for the next two months using scipy.integrate?

E.g. If 2009-01-01 has 5 as the value, I am trying to find the integral below and above 5 for the next two months, depending on the points for the next two months.

EDIT: I guess I don't know what to use as the function since the function is unknown and I only have points to use to integrate. I am thinking I may have to integrate for each day and sum up for the two months?

Below is a sample of my dataset:

DATE             Y
2008-01-01       4
2008-01-02       10.4
2008-01-03       2
2008-01-04       9
2008-01-05       4.3
2008-01-06       7
2008-01-07       8.2
2008-01-08       5
2008-01-09       6.5
2008-01-10       2.3
...
2008-02-28       6.6
2008-03-01       7
2008-03-02       5.4

My objective is to start from 2008-01-01 with a value of 4 and use that as the reference point and find the integral below and above 4 (i.e. 4 to each day's y value) for the next two months. So it will not be a rolling integral but a looking-forward one.

0 个答案:

没有答案