有人可以解释为什么我会收到此错误以及如何解决它吗?我正在尝试搜索 98-99 年的标题,我想获得第一部分(98):
示例标题:CAR EBC 98-99
TypeError: 'NoneType' object is not subscriptable
year_min 行是发生错误的地方。
import pandas as pd
import re
fileinString = 'a.csv'
df1 = pd.read_csv(fileinString, sep=",")
# split title of df1 into string and year tag min and year tag max
regular_expression = re.compile(r'\d\d-\d\d')
title_string = df1['*Title']
year_min = title_string.apply(lambda x: regular_expression.search(x)[0].split('-')[0])
year_max = df1['*Title'].apply(lambda x: regular_expression.search(x)[0].split('-')[1])
print(year_min)
关闭它运行的示例,但它不起作用: https ://ideone.com/JANVt2