键盘错误讯息

时间:2018-06-27 20:09:48

标签: python keyerror

import csv
import os
import pandas as pd
os.chdir('C:\\Users\\khalha\\Desktop\\RealExcel')
filename = 'sales.csv'

Sales = pd.read_csv('sales.csv')
iFlow = Sales.loc[Sales['Product'].str.contains('iFlow', na=False)]["Status"]
print(iFlow)

我遇到了错误:

  File "pandas\_libs\index.pyx", line 140, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\index.pyx", line 162, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\hashtable_class_helper.pxi", line 1492, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas\_libs\hashtable_class_helper.pxi", line 1500, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Status'

我不知道为什么得到这个,因为我在另一个Excel电子表格中使用了相同的代码,并且效果很好。

0 个答案:

没有答案