How can one transform the tmp dataframe to be a 2-element Vector in the same format as rand(2) produces? Thank you for the help! Sorry for the simple questions.
using DataFrames
x = rand(3)
y = rand(3)
z = rand(3)
df = DataFrame(x=x, y=y, z=z)
edit: one caveat for collect versus Vector/Matrix is that the latter coerces its arguments to a uniform element type if possible, which may or may not be what you want.
Why does the below change error (i.e, changed y column and how the dataframe row is selected)?
ERROR: MethodError: no method matching length(::DataFrame)
using DataFrames
x = rand(3)
y = [“a”, “b”, “c”]
z = rand(3)
df = DataFrame(x=x, y=y, z=z)
tmp = df[df.y .== “b”, [:x, :z]]
collect(tmp)
And in DataFrame case it makes no sense to convert it to a Vector since it is a 2-dimensional object; you can convert it to a matrix by writing Matrix(tmp).