从导入到python的Excel文件中打印特定列

时间:2018-11-14 16:59:39

标签: python

我有一张桌子,如下:

Mapping

如何为特定列打印所有带有'X'的源?例如,如果我要指定"Make",则output应该是:

Delivery
Reputation
Profitability

PS:的想法是将Excel文件导入python并执行此操作。

1 个答案:

答案 0 :(得分:0)

使用熊猫

import pandas as pd

filename = "yourexcelfile"
dataframe = pd.read_excel(filename)
frame  = dataframe.loc[dataframe["make"] == "X"]
print(frame["source"])