事实证明,答案中有这样的问题。但我只想看['store1']。你需要做什么?你知道吗
def answer_ups():
import pandas as pd
bla = pd.DataFrame([{'Name': 'Chris', 'Item Purchased': 'Sponge', 'Cost': 202.50},
{'Name': 'Kevyn', 'Item Purchased': 'Kitty Litter', 'Cost': 232.50},
{'Name': 'Filip', 'Item Purchased': 'Spoon', 'Cost': 100}],
index=['Store 1', 'Store 2', 'Store 3'])
bla ['NewCost'] = bla ['Cost'] * 1.15
ququ = bla ['NewCost'].sort_values(ascending=False)
return ququ [1:2]
answer_ups()
应答(存储1 232.875)
如果您只需要'store1'部分,只需返回这个
return ['Store 1', ququ['Store 1']]
它将输出:
['Store 1', 232.87499999999997]
因为函数
answer_ups()
ququ是Series
,所以这里给出了一些Series indexing
。你知道吗考虑到他的观点,你的qqu变量是
第一列是可以通过这种方式访问的索引:
第二列是NewCost值,您可以通过以下方式访问:
相关问题 更多 >
编程相关推荐