JuliaIO / JLD.jl

Saving and loading julia variables while preserving native types
MIT License
277 stars 55 forks source link

CategoricalArray do not seem supported (Stackoverflow) #277

Closed kafisatz closed 3 years ago

kafisatz commented 4 years ago

I get a StackOverflowError for this MWE (Windows, Julia 1.4)

using Pkg 
Pkg.activate(mktempdir())
Pkg.add("JLD");Pkg.add("DataFrames")

using JLD
using DataFrames

df=DataFrame(x=rand(100),y=repeat(vcat("a"),100))

fi=joinpath(mktempdir(),"afile.jld")
@save fi df

fi=joinpath(mktempdir(),"bfile.jld")
categorical!(df) 
@save fi df #fails

 versioninfo()
Julia Version 1.4.2
Commit 44fa15b150* (2020-05-23 18:35 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i9-7980XE CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 16
  JULIA_EDITOR = "C:\Program Files\Microsoft VS Code\Code.exe"

(jl_cm7Gdp) pkg> st
Status `C:\Users\bernhard.konig\AppData\Local\Temp\jl_cm7Gdp\Project.toml`
  [a93c6f00] DataFrames v0.21.3
  [4138dd39] JLD v0.10.0
kafisatz commented 4 years ago

I note that PooledArray works just fine, thus I used this workaround (which is sufficient for my current use case) to first convert to String[] and then to PooledArray

df[!,i] = DataFrames.PooledArrays.PooledArray(convert(Vector{String},df[!, i]))

kafisatz commented 3 years ago

categorical!(df) seems to be an outdated function.