我有以下Python字典列表。
我需要实现一个列表
list_of_dict = [
{'id': 0, 'au_type': 1, 'sequence_id': 0, 'AU_start_position': 0},
{'id': 1, 'au_type': 1, 'sequence_id': 0, 'AU_start_position': 4095},
{'id': 2, 'au_type': 1, 'sequence_id': 0, 'AU_start_position': 8092},
{'id': 0, 'au_type': 3, 'sequence_id': 0, 'AU_start_position': 5678},
{'id': 0, 'au_type': 1, 'sequence_id': 1, 'AU_start_position': 13525},
{'id': 1, 'au_type': 1, 'sequence_id': 1, 'AU_start_position': 13587},
{'id': 2, 'au_type': 1, 'sequence_id': 1, 'AU_start_position': 14576},
{'id': 0, 'au_type': 3, 'sequence_id': 1, 'AU_start_position': 15019},
{'id': 1, 'au_type': 3, 'sequence_id': 1, 'AU_start_position': 15560},
{'id': 2, 'au_type': 3, 'sequence_id': 1, 'AU_start_position': 16004}
]
我有一个变量seq_count
,表示不同的'sequence_id'
数量,另一个变量num_classes
表示不同的'au_type'
数量。
在上面的例子中:
seq_count = 2
num_classes = 2
我需要实现一个列表
numid_seq_cl[seq_count][num_classes]
,返回具有相同'au_type'
和'sequence_id'
的不同'id'
数。
在上面的例子中,numid_seq_cl[0][1] = 3
numid_seq_cl[0][3] = 1
numid_seq_cl[1][1] = 3
numid_seq_cl[1][3] = 3