# Buggy code
def group_serie(self, granularity, start=0):
    # NOTE(jd) Our whole serialization system is based on Epoch, and we
    # store unsigned integer, so we can't store anything before Epoch.
    # Sorry!
    if self.ts.index[0].value < 0:
        raise BeforeEpochError(self.ts.index[0])

    return GroupedTimeSeries(self.ts[start:], granularity)


# Traceback (IndexError)
2017-06-02 16:59:03.590093 mod_wsgi (pid=16031): Exception occurred processing WSGI script '/var/www/gnocchi/app.wsgi'.
2017-06-02 16:59:03.590234 Traceback (most recent call last):
2017-06-02 16:59:03.590304   File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 131, in __call__
2017-06-02 16:59:03.590391     resp = self.call_func(req, *args, **self.kwargs)
2017-06-02 16:59:03.590458   File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 196, in call_func
2017-06-02 16:59:03.590525     return self.func(req, *args, **kwargs)
2017-06-02 16:59:03.590576   File "/usr/local/lib/python2.7/dist-packages/oslo_middleware/base.py", line 126, in __call__
2017-06-02 16:59:03.590636     response = req.get_response(self.application)
2017-06-02 16:59:03.590689   File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1316, in send
2017-06-02 16:59:03.590756     application, catch_exc_info=False)
2017-06-02 16:59:03.590806   File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1280, in call_application
2017-06-02 16:59:03.590871     app_iter = application(self.environ, start_response)
2017-06-02 16:59:03.590926   File "/usr/local/lib/python2.7/dist-packages/paste/urlmap.py", line 216, in __call__
2017-06-02 16:59:03.590982     return app(environ, start_response)
2017-06-02 16:59:03.591033   File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 131, in __call__
2017-06-02 16:59:03.591097     resp = self.call_func(req, *args, **self.kwargs)
2017-06-02 16:59:03.591149   File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 196, in call_func
2017-06-02 16:59:03.591211     return self.func(req, *args, **kwargs)
2017-06-02 16:59:03.591260   File "/usr/local/lib/python2.7/dist-packages/oslo_middleware/base.py", line 126, in __call__
2017-06-02 16:59:03.591322     response = req.get_response(self.application)
2017-06-02 16:59:03.591373   File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1316, in send
2017-06-02 16:59:03.591435     application, catch_exc_info=False)
2017-06-02 16:59:03.591484   File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1280, in call_application
2017-06-02 16:59:03.591538     app_iter = application(self.environ, start_response)
2017-06-02 16:59:03.591590   File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 131, in __call__
2017-06-02 16:59:03.591642     resp = self.call_func(req, *args, **self.kwargs)
2017-06-02 16:59:03.591692   File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 196, in call_func
2017-06-02 16:59:03.591752     return self.func(req, *args, **kwargs)
2017-06-02 16:59:03.591802   File "/usr/local/lib/python2.7/dist-packages/keystonemiddleware/auth_token/__init__.py", line 335, in __call__
2017-06-02 16:59:03.591871     response = req.get_response(self._app)
2017-06-02 16:59:03.591921   File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1316, in send
2017-06-02 16:59:03.591983     application, catch_exc_info=False)
2017-06-02 16:59:03.592032   File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1280, in call_application
2017-06-02 16:59:03.592095     app_iter = application(self.environ, start_response)
2017-06-02 16:59:03.592139   File "/usr/local/lib/python2.7/dist-packages/webob/exc.py", line 1162, in __call__
2017-06-02 16:59:03.592202     return self.application(environ, start_response)
2017-06-02 16:59:03.592243   File "/opt/stack/gnocchi/gnocchi/rest/app.py", line 69, in __call__
2017-06-02 16:59:03.592302     return self.app(environ, start_response)
2017-06-02 16:59:03.592363   File "/usr/local/lib/python2.7/dist-packages/pecan/middleware/recursive.py", line 56, in __call__
2017-06-02 16:59:03.592434     return self.application(environ, start_response)
2017-06-02 16:59:03.592476   File "/usr/local/lib/python2.7/dist-packages/pecan/core.py", line 840, in __call__
2017-06-02 16:59:03.592529     return super(Pecan, self).__call__(environ, start_response)
2017-06-02 16:59:03.592760   File "/usr/local/lib/python2.7/dist-packages/pecan/core.py", line 683, in __call__
2017-06-02 16:59:03.592830     self.invoke_controller(controller, args, kwargs, state)
2017-06-02 16:59:03.592873   File "/usr/local/lib/python2.7/dist-packages/pecan/core.py", line 574, in invoke_controller
2017-06-02 16:59:03.592935     result = controller(*args, **kwargs)
2017-06-02 16:59:03.592984   File "/opt/stack/gnocchi/gnocchi/rest/__init__.py", line 1536, in post
2017-06-02 16:59:03.593042     granularity, needed_overlap, fill, refresh, resample)
2017-06-02 16:59:03.593096   File "/opt/stack/gnocchi/gnocchi/rest/__init__.py", line 1657, in get_cross_metric_measures_from_objs
2017-06-02 16:59:03.593164     reaggregation, resample, granularity, needed_overlap, fill)
2017-06-02 16:59:03.593209   File "/opt/stack/gnocchi/gnocchi/storage/_carbonara.py", line 506, in get_cross_metric_measures
2017-06-02 16:59:03.593275     tss[i] = ts.resample(resample)
2017-06-02 16:59:03.593324   File "/opt/stack/gnocchi/gnocchi/carbonara.py", line 522, in resample
2017-06-02 16:59:03.593385     self.group_serie(sampling), sampling, self.aggregation_method)
2017-06-02 16:59:03.593440   File "/opt/stack/gnocchi/gnocchi/carbonara.py", line 249, in group_serie
2017-06-02 16:59:03.593502     if self.ts.index[0].value < 0:
2017-06-02 16:59:03.593542   File "/usr/local/lib/python2.7/dist-packages/pandas/indexes/base.py", line 1423, in __getitem__
2017-06-02 16:59:03.593610     return getitem(key)
2017-06-02 16:59:03.593655 IndexError: index 0 is out of bounds for axis 0 with size 0```

# Fixed code
def group_serie(self, granularity, start=0):
    # NOTE(jd) Our whole serialization system is based on Epoch, and we
    # store unsigned integer, so we can't store anything before Epoch.
    # Sorry!
    if not self.ts.empty and self.ts.index[0].value < 0:
        raise BeforeEpochError(self.ts.index[0])

    return GroupedTimeSeries(self.ts[start:], granularity)