Skip to content
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

Julia crashes when doing levels! on a DataFrame column #1634

Closed
pascalgolec opened this issue Dec 13, 2018 · 2 comments
Closed

Julia crashes when doing levels! on a DataFrame column #1634

pascalgolec opened this issue Dec 13, 2018 · 2 comments

Comments

@pascalgolec
Copy link

Julia 1.0.2, DataFrames v0.15.2 and CategoricalArrays v0.5.2 gives me an interpreter error that crashes julia when using levels! on a DataFame column directly:

# crashes:
using DataFrames
mycats = ["a", "b"]
mydf = DataFrame(x = ["a", "b", "a"])
function cat!(df::DataFrame, cats::Vector{String})
    df.x = CategoricalArray(df.x)
    levels!(df.x, cats) # julia crashes here
    return df
end
mydf = cat!(mydf, mycats)

These two scenarios on the other hand work:

# works if levels! is outside of function
using DataFrames
mycats = ["a", "b"]
mydf = DataFrame(x = ["a", "b", "a"])
function cat!(df::DataFrame, cats::Vector{String})
    df.x = CategoricalArray(df.x)
    return df
end
mydf = cat!(mydf, mycats)
levels!(mydf.x, mycats)
# works if don't apply levels! on a DataFrame column:
using CategoricalArrays
mycats = ["a", "b"]
x = ["a", "b", "a"]
function cat!(vec::Vector{String}, cats::Vector{String})
    vec = CategoricalArray(vec)
    levels!(vec, cats) # julia crashes here
    return vec
end
cat!(x, mycats)
@bkamins
Copy link
Member

bkamins commented Dec 13, 2018

I think this is a known issue with Julia compiler. CategoricalArrays.jl stress it to the extreme. Similar issues have been reported, see JuliaLang/julia#25430, but I think @nalimilan might know if they cover this case.

@nalimilan
Copy link
Member

Yes I think that's JuliaLang/julia#29430. It's fixed in Julia 1.1. Unfortunately it hasn't been backported to 1.0.3 because it could break existing code, and we haven't been able to run checks on packages to see whether that's the case or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants