我在加载(800,000,9)的csv文件时遇到问题,如下所示。
npa = pd.read_csv("large_scale_data.csv", usecols=[3,5,6, 7, 8, 9], header=None,low_memory=False)
for img in char:
img_cv = cv2.imread(path_img+'/'+ img +'.png')
images = []
images_names = []
WIDTH=[]
HEIGHT=[]
for i in range(1, nb_charac):
if (img==npa.iloc[i,0]):
coords = npa.iloc[[i]]
img_charac = img_cv[int(coords[8]):int(coords[9]), int(coords[6]):int(coords[7])]
我在这一行得到了一个错误:
img_charac = img_cv[int(coords[8]):int(coords[9]), int(coords[6]):int(coords[7])]
参考这一行
npa = pd.read_csv("large_scale_data.csv", usecols=[3,5,6, 7, 8, 9], header=None, low_memory=False)
错误是:
npa = pd.read_csv("large_scale_data.csv", usecols=[3,5,6, 7, 8, 9], header=None,low_memory=False)
sys:1: DtypeWarning: Columns (6,7,8,9) have mixed types. Specify dtype option on import or set low_memory=False.
Traceback (most recent call last):
img_charac = img_cv[int(coords[8]):int(coords[9]), int(coords[6]):int(coords[7])]
TypeError: 'NoneType' object has no attribute '__getitem__'
然而,相同的代码适用于(10,000,9)的csv文件。怎么了?