code: def clipped_area(ts, thresh=0, integrator=integrate.trapz):
      
      integrator = get_integrator(integrator or 0)
      ts = insert_crossings(ts, thresh) - thresh
      ts = ts[ts >= 0]
      # timestamp is in nanoseconds (since 1/1/1970) but this converts it to seconds (SI units)
      return integrator(ts, ts.index.astype(np.int64)) / 1.0e9
docs: Total value * time above the starting value within a TimeSeries
  
      Arguments:
        ts (pandas.Series): Time series to be integrated.
        thresh (float): Value to clip the tops off at (crossings will be interpolated)
  
      References:
        http://nbviewer.ipython.org/gist/kermit666/5720498
  
      >>> t = ['2014-12-09T00:00', '2014-12-09T00:15', '2014-12-09T00:30', '2014-12-09T00:45',
      ...      '2014-12-09T01:00', '2014-12-09T01:15', '2014-12-09T01:30', '2014-12-09T01:45']
      >>> import pandas as pd
      >>> ts = pd.Series([217, 234, 235, 231, 219, 219, 231, 232], index=pd.to_datetime(t))
      >>> clipped_area(ts, thresh=230)  # doctest: +ELLIPSIS
      8598.52941...
      >>> clipped_area(ts, thresh=234)  # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
      562.5
      >>> clipped_area(pd.Series(ts.values, index=ts.index.values.astype(pd.np.int64)),
      ...              thresh=234)  # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
      562.5