,可以通过以下步骤实现:
完整的代码如下:
data = [
[1, 5, 3, 2],
[4, 2, 6, 1],
[7, 1, 9, 8]
]
second_highest = [sorted(row)[-2] for row in data]
indices = [row.index(value) for row, value in zip(data, second_highest)]
column_names = ['A', 'B', 'C', 'D']
second_highest_column = [column_names[index] for index in indices]
print(second_highest_column)
输出结果为:['B', 'C', 'A'],表示每行中第二高值所在的列名称分别为B、C和A。
腾讯云相关产品和产品介绍链接地址:
没有搜到相关的沙龙
领取专属 10元无门槛券
手把手带您无忧上云