-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use NullableArray in a data frame #933
Comments
To anyone else who sees a similar error and ends up here: DataFrames with NullableArray columns need to be constructed all at once, and can't currently have additional columns added. This means that while you can do things like: DataFrame(Any[NullableArray([1,2])], Symbol[:y]) to construct a DataFrame, you can't subsequently add more columns with something like df[:col] = NullableArray([1,2])
If you have a DataFrame with NullableArrays for columns and you need to add columns or otherwise convert it to a vanilla DataFrame (with DataArray columns) you can use something like function NullableDFtoDF!(ndf)
for c in names(ndf)
ndf[c] = DataArray(ndf[c].values, ndf[c].isnull)
end
end
function DFtoNullableDF(df)
DataFrame(Any[NullableArray(df[c].data,
Array{Bool}(df[c].na)) for c in names(df)], names(df))
end |
See #1008. |
I see this with latest master of DataFrames and NullableArrays:
I suspect I'm missing something, since people seem to be doing this all the time (e.g. JuliaData/DataFramesMeta.jl#42).
The text was updated successfully, but these errors were encountered: