def hydro_area_lookup(area_id, df_ref, area_key):
    """Get max row in data file of a particular area's grid cells to reduce row count for performance

    :param area_id:                 ID of area to find it's grid cells
    :type area_id:              int

    :param df_ref:                  Reference dataframe
    :type df_ref:                   dataframe

    :area_key:                      Type of area (country or basin)
    :type area_key:                 str

    :return:                        int; Max row of area in file data

    """

    # get which grid cells are associated with the target basin
    target_idx_list = df_ref[df_ref[area_key] == area_id].copy()
    return max(target_idx_list['grid_id'])