<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def compute_range(travel_data, attr, travel_time_attr, dist, agg=np.sum):
 """ Compute a zone-based accessibility query using the urbansim format travel data dataframe. Parameters travel_data : dataframe The dataframe of urbansim format travel data. Has from_zone_id as first index, to_zone_id as second index, and different impedances between zones as columns. attr : series The attr to aggregate. Should be indexed by zone_id and the values will be aggregated. travel_time_attr : string The column name in travel_data to use as the impedance. dist : float The max distance to aggregate up to agg : function, optional, np.sum by default The numpy function to use for aggregation """

    travel_data = travel_data.reset_index(level=1)
    travel_data = travel_data[travel_data[travel_time_attr] < dist]
    travel_data["attr"] = attr[travel_data.to_zone_id].values
    return travel_data.groupby(level=0).attr.apply(agg)