使用python中的“pandas”库时,此代码出现问题:
正在尝试在“int”列中应用.apply()方法。 在我制作def并尝试使用(if,else)之前
但我得到以下错误:
TypeError: ("'> =' not supported between instances of 'list' and 'int'", 'occurred at index A View to a Kill')
我试图将'Year'列从int64传递到'Str'。但它给了我几乎相同的错误。你知道吗
bond = pd.read_csv('jamesbond.csv', index_col = 'Film')
bond.sort_index(inplace = True)
bond.head(3)
def classic_modern(row):
year = [0]
if year >= 1990 :
return 'The movie is modern'
else :
return 'The movie is old one'
bond.apply(classic_modern , axis = 1)
此行初始化具有1个值
0
的列表:接下来将此列表与整数进行比较,从而导致错误:
相关问题 更多 >
编程相关推荐