I’d appreciate help to understand the following. The particular code here with a problem is using a @select
expression to extract the second number embedded in a string in DataFrame column elements which have the type of Union{String, Missing}
, but I expect the difficulty will probably arise with other variations (eg. I can confirm this fails with @where
statements of similar form):
c1=Union{String, Missing}["a4 - 1.0","b5 - 2.0","c6 - 3.0"]
df2 = DataFrame(Frame=c1)
# Gives error (see below)
df3 = @from i in df2 begin
@select {time=parse(Float64,string(match(r"[^\d]*[\d.]+[^\d]+([\d.]+)",i.Frame)[1])) } # This is an error
@collect DataFrame
end
# Good if I add extra string() conversion
df4 = @from i in df2 begin
@select {time=parse(Float64,string(match(r"[^\d]*[\d.]+[^\d]+([\d.]+)",string(i.Frame))[1])) }
@collect DataFrame
end
However the @select
transformation expression above that gives an error works fine in “regular” Julia use
println("Extract 2nd digit: $(parse(Float64,string(match(r"[^\d]*[\d.]+[^\d]+([\d.]+)",c1[1])[1] ))))")
Is this a bug?
Many thanks,
GC
PS. The error thrown is:
LoadError: ArgumentError: unable to construct DataFrame from QueryOperators.EnumerableMap{Union{},QueryOperators.EnumerableIterable{NamedTuple{(:Frame, :Step),Tuple{DataValues.DataValue{String},DataValues.DataValue{String}}},Tables.DataValueRowIterator{NamedTuple{(:Frame, :Step),Tuple{DataValues.DataValue{String},DataValues.DataValue{String}}},Tables.RowIterator{NamedTuple{(:Frame, :Step),Tuple{Array{Union{Missing, String},1},Array{Union{Missing, String},1}}}}}},getfield(Main, Symbol("##269#270"))}
in expression starting at C:\Users\tcd\Dropbox (Personal)\Prof\TCD\Comm\Manuscript-19\Glass mech\Thin film yield\Analysis\queryPlay2.jl:32
#DataFrame#366(::Bool, ::Type, ::QueryOperators.EnumerableMap{Union{},QueryOperators.EnumerableIterable{NamedTuple{(:Frame, :Step),Tuple{DataValues.DataValue{String},DataValues.DataValue{String}}},Tables.DataValueRowIterator{NamedTuple{(:Frame, :Step),Tuple{DataValues.DataValue{String},DataValues.DataValue{String}}},Tables.RowIterator{NamedTuple{(:Frame, :Step),Tuple{Array{Union{Missing, String},1},Array{Union{Missing, String},1}}}}}},getfield(Main, Symbol("##269#270"))}) at tables.jl:35
DataFrame(::QueryOperators.EnumerableMap{Union{},QueryOperators.EnumerableIterable{NamedTuple{(:Frame, :Step),Tuple{DataValues.DataValue{String},DataValues.DataValue{String}}},Tables.DataValueRowIterator{NamedTuple{(:Frame, :Step),Tuple{DataValues.DataValue{String},DataValues.DataValue{String}}},Tables.RowIterator{NamedTuple{(:Frame, :Step),Tuple{Array{Union{Missing, String},1},Array{Union{Missing, String},1}}}}}},getfield(Main, Symbol("##269#270"))}) at tables.jl:20
top-level scope at none:0