麻烦.apply()带'int'列的方法

青春须早为,岂能长少年。这篇文章主要讲述麻烦.apply()带' int' 列的方法相关的知识,希望能为你提供帮助。
使用python中的'pandas'库来解决此代码的问题:
尝试将.apply()方法应用于'int'列。在我做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
year = [0]

【麻烦.apply()带' int' 列的方法】接下来,将此列表与整数进行比较,从而导致错误:
if year > = 1990:# if [0] > = 1990


    推荐阅读