我有下列项目列表:的Python:获得最大的价值对象唯一键
[
{'country' : 'India', 'date' : '18-Mar-14'},
{'country' : 'India', 'date' : '18-Apr-14'},
{'country' : 'India', 'date' : '18-May-14'},
{'country' : 'Australia', 'date' : '18-Mar-14'},
{'country' : 'Australia', 'date' : '18-Apr-14'},
{'country' : 'Australia', 'date' : '18-May-14'},
{'country' : 'China', 'date' : '18-Mar-14'},
{'country' : 'China', 'date' : '18-Apr-14'},
{'country' : 'China', 'date' : '18-May-14'}
]
我怎样才能获得仅包含最大日期值对每个国家,即它返回一个包含项目每个国家的项目那个日期最大的国家。在这种情况下,结果列表将为:
[
{'country' : 'India', 'date' : '18-May-14'},
{'country' : 'Australia', 'date' : '18-May-14'},
{'country' : 'China', 'date' : '18-May-14'},
]
你能否澄清 “大日”?你的意思是“最近的”? –
按国家分组,然后从该组中取“最大日期” – Melon
是最近的日期。因为我的数据非常庞大,什么才是复杂性最高的最有效的方法。 –