我正在python中运行一段代码,运行后会产生以下错误:
... reading line 1400000 from file users.csv
Traceback (most recent call last):
File "xgb.py", line 32, in <module>
(header_items, items) = select(ITEMS_FILE, lambda x: True, build_item, lambda x: int(x[0]))
File "/Users/yas/Documents/GitHub/fairness/2017-master/baseline/parser.py", line 34, in select
obj = toObject(cmp, header)
File "/Users/yas/Documents/GitHub/fairness/2017-master/baseline/parser.py", line 56, in build_item
[int(x) for x in str_item[names["title"]].split(",") if len(x) > 0],
TypeError: 'NoneType' object is not subscriptable
The error is pointing me to this part of the code:
def build_item(str_item, names):
return Item(
[int(x) for x in str_item[names["title"]].split(",") if len(x) > 0],
int(str_item[names["career_level"]]),
int(str_item[names["industry_id"]]),
int(str_item[names["discipline_id"]]),
str_item[names["country"]],
str_item[names["region"]]
)
请问如何解决?