Python 类型错误:';非类型';对象没有属性'__获取项目';加载巨大的csv数据时出错
我在加载(800000,9)的csv文件时遇到问题,如下所示Python 类型错误:';非类型';对象没有属性'__获取项目';加载巨大的csv数据时出错,python,csv,pandas,opencv,Python,Csv,Pandas,Opencv,我在加载(800000,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 =
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__'
然而,同样的代码可以很好地处理csv文件(10000,9)。怎么了?这意味着
img\u cv
正在变成None
。检查cv2.imread
的文档,查看它返回None
的含义。确保它是正确的路径“警告即使图像路径错误,它也不会抛出任何错误,但print img不会为您提供任何”由于路径中缺少“/”而解决的感谢问题。然而,我总是得到sys:1:DtypeWarning:Columns(6,7,8,9)的混合类型。在导入时指定dtype选项或将低内存设置为False。即使我设置为低_内存=错误。怎么了?