def subset(df, lb=None, ub=None, param='capacity_fraction', sum_param='length'
    ):
    """
    subset a Dataframe between the provided lowerbound and upperbound (lb, ub)
    along the given parameter. optionally return a scalar sum of data within the
    sum_param
    """
    if lb is not None:
        df = df.loc[df[param] >= lb]
    if ub is not None:
        df = df.loc[df[param] < ub]
    if sum_param is not None:
        return df[sum_param].sum()
    else:
        return df
