Getting this error Message MethodError: no method matching getindex(::DataFrame, ::String) but method is there (I m trying to do the kaggle dataset "https://www.kaggle.com/c/street-view-getting-started-with-julia/overview" )

ERROR: LoadError: MethodError: no method matching getindex(::DataFrame, ::String)
Closest candidates are:
getindex(::DataFrame, !Matched::Symbol) at C:\Users\user.julia\packages\DataFrames\IKMvt\src\dataframe\dataframe.jl:252
getindex(::DataFrame, !Matched::Colon) at C:\Users\user.julia\packages\DataFrames\IKMvt\src\dataframe\dataframe.jl:264
getindex(::DataFrame, !Matched::Colon, !Matched::Colon) at C:\Users\user.julia\packages\DataFrames\IKMvt\src\dataframe\dataframe.jl:339

Stacktrace:
[1] read_data(::String, ::DataFrame, ::Int64, ::String) at F:\Kaggle\myreport.jl:10
[2] top-level scope at none:0
[3] include at .\boot.jl:326 [inlined]
[4] include_relative(::Module, ::String) at .\loading.jl:1038
[5] include(::Module, ::String) at .\sysimg.jl:29
[6] exec_options(::Base.JLOptions) at .\client.jl:267
[7] _start() at .\client.jl:436
in expression starting at F:\Kaggle\myreport.jl:31

This is my code

function read_data(typeData, labelsInfo, imageSize, path)
 #Intialize x matrix
 x = zeros(size(labelsInfo, 1), imageSize)

 for (index, idImage) in enumerate(labelsInfo["ID"])
  #Read image file
  nameFile = "$(path)/$(typeData)Resized/$(idImage).Bmp"
  img = load(nameFile)

  temp = Gray.(img)

  #Transform image matrix to a vector and store
  #it in data matrix
  x[index, :] = reshape(temp, 1, imageSize)
 end
 return x
end

imageSize  = 400

path = "street-view-getting-started-with-julia"

labelsInfoTrain = CSV.read("$(path)/trainLabels.csv")

xTrain = read_data("train", labelsInfoTrain, imageSize, path)

labelsInfoTest = CSV.read("$(path)/sampleSubmission.csv")

xTest = read_data("test", labelsInfoTest, imageSize, path)

Welcome to the forums! Please take a look at this post, and follow it’s guidelines to help us help you. Simply posting an error message without context is unlikely to solicit much help.

2 Likes

sorry, for that but now I have updated my Query

No worries! You should also quote your code with 3 backticks:

```
foo(x) = x + 2

y = foo(42)
```
1 Like