使用Juno/LT运行Julia代码,错误,`getindex`没有与getindex(::DataFrame,::ascistring)匹配的方法

使用Juno/LT运行Julia代码,错误,`getindex`没有与getindex(::DataFrame,::ascistring)匹配的方法,julia,Julia,下面是我正在使用的代码的第一部分。此代码的目的是,当给定一个.bmp格式的图像文件时,正确识别图像中显示的字母 #Install required packages Pkg.add("Images") Pkg.add("DataFrames") using Images using DataFrames #typeData could be either "train" or "test. #labelsInfo should contain the IDs of each image to

下面是我正在使用的代码的第一部分。此代码的目的是,当给定一个.bmp格式的图像文件时,正确识别图像中显示的字母

#Install required packages
Pkg.add("Images")
Pkg.add("DataFrames")
using Images
using DataFrames


#typeData could be either "train" or "test.
#labelsInfo should contain the IDs of each image to be read
#The images in the trainResized and testResized data files
#are 20x20 pixels, so imageSize is set to 400.
#path should be set to the location of the data files.

function read_data(typeData, labelsInfo, imageSize, path)

#Intialize x matrix
 x = zeros(size(labelsInfo, 1), imageSize)

for (index, idImage) in enumerate(labelsInfoTrain["ID"])
  #Read image file
  nameFile = "$(path)/$(typeData)Resized/$(idImage).Bmp"
  img = imread(nameFile)
  #Convert img to float values
  temp = float32sc(img)
  #Convert color images to gray images
  #by taking the average of the color scales.
  if ndims(temp) == 3
   temp = mean(temp.data, 1)
  end
  #Transform image matrix to a vector and store
  #it in data matrix
  x[index, :] = reshape(temp, 1, imageSize)
 end
 return x
end
imageSize = 400 # 20 x 20 pixels

#Set location of data files , folders
#Probably will need to set this path to which folder your files are in
path = "C:\\Users\\Aaron\\Downloads\\Math512Project"

#Read information about test data ( IDs )
labelsInfoTest = readtable("$(path)/sampleSubmissionJulia.csv")

#Read test matrixnformation about training data , IDs.
labelsInfoTrain = readtable("$(path)/trainLabels.csv")

#Read training matrix

xTrain = read_data("train", labelsInfoTrain, imageSize, path)
我面临的错误是当我的程序到达上面的最后一行代码时,该行代码如下:

xTrain = read_data("train", labelsInfoTrain, imageSize, path)
我收到一个错误,它说:
getindex
没有与getindex(::DataFrame,::ascistring in read_data at benchmarkJeff.jl:18)匹配的方法

这是指代码行:

for (index, idImage) in enumerate(labelsInfoTrain["ID"])

一些在线研究让我了解到,问题与使用DataFrames包和Image包时的冲突有关。建议我将代码中的“ID”更改为[:ID],但这并不能解决问题,反而会导致另一个错误。我想知道是否有人知道如何解决这个问题,或者我的代码到底有什么问题。在Julia命令行0.4.0中运行代码时,我也会遇到同样的错误。期待您的回复。

上述错误的原因是您已经提到的,请先重新执行ce[“ID”]具有可能为[:ID]的正确索引,请确保此列存在
名称(labelsInfoTrain)
检查类型
typeof(labelsInfoTrain)
及其大小
size(labelsInfoTrain)
上述错误的原因是您已经提到的,首先用可能为[:ID]的正确索引替换[“ID”],确保此列存在
名称(labelsInfoTrain)
检查类型
类型(labelsInfoTrain)
及其大小
大小(labelsInfoTrain)