def flight_data_and_axis(new_frames):
    """Returns list of lists with the following structure:
    [[flight, [data source, [name, unit, data],[name, unit, data]]], [flight, [data source, [name, unit, data],
    [name, unit, data]]]]."""
    values_list = []
    flight_identifier = new_frames[0].columns[0][-16:]
    for frame in new_frames:
        data_lists = []
        data_lists.append(frame.columns[0].split('_')[-3])
        for column in frame.columns:
            y = frame[column].tolist()
            name = ''
            unit = ''
            b = 0
            if len(column.split('_')) == 5:
                a = 0
                unit_present = True
            elif len(column.split('_')) == 4:
                unit_present = False
                a = 0
            else:
                a = 5 - len(column.split('_'))
            for letter in column:
                if b == 0:
                    name = letter.upper()
                    b = 1
                elif a <= 0:
                    if letter != '_':
                        name = name + letter
                    else:
                        a += 1
                        if a <= 0:
                            name += ' '
                elif letter != '_' and unit_present is True:
                    unit = unit + letter
                elif unit_present is False:
                    unit = 'no unit'
                    break
                else:
                    break
            if 'per' in unit:
                unit_split = unit.split('per')
                denominators = []
                a = 0
                for count in range(1, len(unit_split)):
                    for item in denominators:
                        if unit_split[count] in item[0]:
                            item[1] = item[1] + 1
                            a = 1
                    if a == 1:
                        a = 0
                    else:
                        denominators.append([unit_split[count], 1])
                unit = unit_split[0]
                for denominator in denominators:
                    unit = unit + denominator[0] + '$^{-' + str(denominator[1]
                        ) + '}$'
            data_lists.append([name, unit, y])
        values_list.append(data_lists)
    return [flight_identifier, values_list]
