df[:A] gives you a column, which is vector of Line objects. df[:A][1] gives you the first entry of that vector.
df[:A][1].a gives you the a element of the first entry of that vector. I think you're better off just using a raw vector of immutables. Instead of defining type Line, define immutable Line. -- John On Apr 17, 2014, at 3:33 PM, Stéphane Laurent <laurent_s...@yahoo.fr> wrote: > How do I extract a line and a column with this method ? > > > > Le vendredi 18 avril 2014 00:21:26 UTC+2, John Myles White a écrit : > Each row of a DataFrame is itself a DataFrame. > > Why not just store things in a vector of Line objects? > > type Line{T} > a::T > pair::Int > end > > df = DataFrame(A = Line[Line(1.0, 1), Line(2.0, 2)]) > > I've changed things from your code because there's a convention of using > uppercase letters to start the names of types. > > -- John > > On Apr 17, 2014, at 3:18 PM, Stéphane Laurent <lauren...@yahoo.fr> wrote: > >> Thank you. I need to extract the lines too. A line looks like >> >> type line{T} >> a::T >> pair:Int >> end >> >> This doesn't work, do you have something to propose : >> >> D = DataFrame(A = [1.,2.], B = [1,2]) >> D[1,:]::line{Float64} >> >> ? >> >> Le jeudi 17 avril 2014 23:48:29 UTC+2, Simon Kornblith a écrit : >> The most performant approach would be to store the columns as vectors in a >> tuple or immutable. DataFrames can be nearly as performant if you: >> >> - Extract columns (df[:mycol]) and index into them whenever possible instead >> of indexing individual elements (df[1, :mycol]) >> - Add typeasserts when you perform indexing operations >> (df[:mycol]::Vector{Int}), or pass the columns to another function >> >> Otherwise you will incur a slowdown because the compiler doesn't know the >> types. >> >> Simon >> >> On Thursday, April 17, 2014 5:34:24 PM UTC-4, John Myles White wrote: >> It's actually possible to place pure Julia vectors in a DataFrame, which >> might be convenient in this case. But you could always just store the >> columns in a Vector{Any}, which is what the DataFrame does behind the scenes >> anyway. >> >> -- John >> >> On Apr 17, 2014, at 2:27 PM, Stefan Karpinski <ste...@karpinski.org> wrote: >> >>> A DataFrame does seem like a good option, but those have NA support that >>> you may not need. Can you elaborate a little more on the use case? Is it a >>> fixed set of column names and types? Or will you need to support different >>> schemas? >>> >>> >>> On Thu, Apr 17, 2014 at 5:16 PM, Stéphane Laurent <lauren...@yahoo.fr> >>> wrote: >>> Hello, >>> >>> I need to deal with some objects represented as arrays whose some columns >>> are BigFloat, some columns are Int, some columns are logical. Is it a good >>> idea to use a DataFrame ? Is there a better solution ?This is for a >>> computationally intensive program. >>> >> >