I want to use cumtrapz on a pd.DataFrame
that looks something like this:
TIME VALUE
2020-01-01 12:00:00 10
2020-01-01 12:00:01 -10
2020-01-01 12:02:20 2
2020-01-01 12:10:00 3
... ...
Note that the gaps between the times are irregular, which is why I opt to choose cumtrapz.
Is there a possibility to calculate the negative and positive areas separately? See the image below, I need to calculate + and - and ultimately divide one by the other to receive the relation of positive to negative area.
I know that I could split the pd.DataFrame
into two separate ones, replacing the positive values with 0 in one of them and the negative values with 0 in within the other. Subsequently, I could run cumtrapz on both of them. However, I'm looking for a more accurate method.