import pandas as pd
data = [{'id':0,'city':'Chicago','contrcost':1000000.00},
{'id':1,'city':'New York','contrcost':2000000.00},
{'id':2,'city':'Boston','contrcost':1000000.00},
{'id':3,'city':'Atlanta','contrcost':1000000.00},
{'id':4,'city':'Los Angeles','contrcost':2000000.00}]
df = pd.DataFrame(data)
max_index = df['contrcost'].idxmax()
print('City with the contract that has the greatest cost: {:s} (contract cost is ${:.2f})'
.format( df.iloc[max_index]['city'], df.iloc[max_index]['contrcost']))
我相信这会给你你想要的。
idxmax()
函数返回具有最大值的行的索引。如果有多个,则返回第一个产出:合同成本最高的城市:纽约(合同成本为2000000.00美元)
相关问题 更多 >
编程相关推荐