def fit1d(lower, upper):
    """Fit acceleration data at lower and upper boundaries of gravity

    Args
    ----
    lower: pandas dataframe
        slice of lleo datafram containing points at -1g calibration position
    upper: pandas dataframe
        slice of lleo datafram containing points at -1g calibration position

    Returns
    -------
    p: ndarray
        Polynomial coefficients, highest power first. If y was 2-D, the
        coefficients for k-th data set are in p[:,k]. From `numpy.polyfit()`.

    NOTE
    ----
    This method should be compared agaist alternate linalg method, which allows
    for 2d for 2d poly, see - http://stackoverflow.com/a/33966967/943773

    A = numpy.vstack(lower, upper).transpose()
    y = A[:,1]
    m, c = numpy.linalg.lstsq(A, y)[0]
    """
    import numpy
    idx = min(len(lower), len(upper))
    x = numpy.hstack((lower[:idx].values, upper[:idx].values))
    x = x.astype(float)
    y = numpy.zeros(len(x), dtype=float)
    y[:idx] = -1.0
    y[idx:] = 1.0
    return numpy.polyfit(x, y, deg=1)
