there are several ways of doing the integration. You can do it by hand or you can use available code which uses the same methods.
From my perspective using pandas Dataframes is the most convenient way dealing with data. You have to load your columns into a pandas.Series and then you can use the code given below to compute th integral. The necessary code is available here (https://nbviewer.jupyter.org/gist/metakermit/5720498), but a small change have to be made, because TimeSeries is just a Series. At first start with this code:
from scipy import integrate import pandas as pd import numpy as np def integrate_method(self, how='trapz', unit='s'): '''Numerically integrate the time series. @param how: the method to use (trapz by default) @return Available methods: * trapz - trapezoidal * cumtrapz - cumulative trapezoidal * simps - Simpson's rule * romb - Romberger's rule See http://docs.scipy.org/doc/scipy/reference/integrate.html for the method details. or the source code https://github.com/scipy/scipy/blob/master/scipy/integrate/quadrature.py ''' available_rules = set(['trapz', 'cumtrapz', 'simps', 'romb']) if how in available_rules: rule = integrate.__getattribute__(how) else: print('Unsupported integration rule: %s' % (how)) print('Expecting one of these sample-based integration rules: %s' % (str(list(available_rules)))) raise AttributeError result = rule(self.values, self.index.astype(np.int64) / 10**9) #result = rule(self.values) return result pd.Series.integrate = integrate_method
Than you can create your series object with your data and simply run ts.integrate.