Julia: How to replace SQLite.Null with NA in DataFrame -
i have sqlite database read dataframe in julia. when values missing, given type sqlite.null, difficult deal with. prefer nas. there easy way conversion? kludgy way follows:
using dataframes, sqlite df = dataframe() df[:x1] = [1, sqlite.nulltype(), 3, 4] df[:x2] = ["a", "b", sqlite.nulltype(), "d"] function repnull(x) if isa(x, sqlite.nulltype) return(na) else return(x) end end df[:1] = map(repnull, df[:x1]) df[:2] = map(repnull, df[:x2])
is there more elegant and/or efficient way?
i've looked question i'm new julia may have been using wrong terms.
the following seems readable , fast.
for col in df.columns col[col.==sqlite.null]=na end
a curious thing note 'exceptional' behaviour of na
under equality. thus, above solution may throw exception if there na
s in dataframe (i.e. operation not idempotent).
Comments
Post a Comment