Hi Guys,
I got a super easy question:
when I want to convert a DataFrameRow with the same type to a Vector, I saw from some thread to use:
Vector(data[1,:])
#or
convert(Vector, data[1,:])
but some times I got the error message that: MethodError: Cannot convert an object of type DataFrameRow{DataFrame, DataFrames.Index} to an object of type Vector{Int64}
PS: I finally end up using collect(values(data[1:])) where the values function would return a NTuple and use collect to make it a vector
Could any one tell me the best way or correct way to do it ?
You were close. Usually convert and the constructor are used for things which as “very alike”. A DataFrameRow isn’t close enough to qualify for that I guess. You want
Sorry for the late reply, I thought it was solved.
I encountered the issue from the course’s problem set 1: mitmath/6S083: Materials for MIT 6.S083 / 18.S190: Computational thinking with Julia + application to the COVID-19 pandemic (github.com) which is offered by Julia academy.
And I try to run the error code but it seems to work now, the error was shown in a for-loop when I convert the DataFrameRow to a vector, so I tested it separately, and Vector(data[1,:]) seems to work, and I could not figure out why so I post this problem and used sometimes to describe it. After I switch to use collect(data[1,:]) there is no error anymore, so I didn’t think too much.
So I think maybe there is no bug in the source code, it could probably be my problem. So sorry for that, maybe you should close the issue. Big thanks for always giving the most effective solutions that help me a lot in the journey to learn Julia lang.