【问题标题】:how to select the maximum value keyframe from the python dictionary如何从python字典中选择最大值关键帧
【发布时间】:2022-06-14 22:55:40
【问题描述】:

我有python字典如下;

betweeness = {'1': 0.0, '2': 0.0, '3': 0.012383661306863258, '5': 0.2325097571925996, '9': 0.021426274633144952, '13': 0.0, '51': 0.020636786004927934, '58': 0.0, '101': 0.050549206468619164}

从上述字典中选择最大值生成关键帧的最简单方法是什么(即,根据上述字典,关键帧 = '5')

【问题讨论】:

  • max(betweeness.items(), key=operator.itemgetter(1))[0]

标签: python pandas dataframe dictionary networkx


【解决方案1】:

使用max

print(max(betweeness, key=lambda x: betweeness[x]))

【讨论】:

    猜你喜欢
    • 2020-03-16
    • 1970-01-01
    • 1970-01-01
    • 2015-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-12
    相关资源
    最近更新 更多