I’m having trouble initializing an empty dataframe intended to hold integer and floating point values:
julia> using DataFrames
julia> df = DataFrame([Int,Float64], :auto)
Row │ x1 x2
│ Float64 Float64
1 │ 1.0 10.0
Why is the first column a
Float64 rather than an
Int? I’m using
DataFrames version 1.2.1 with Julia 1.6.2.
Not sure why it behaves like that in this case and if it is intended. But as a quick workaround, if you can assign column names and do:
df = DataFrame(a = Int64, b = Float64)
then the types are as expected.
This isn’t about DataFrames, but rather auto-promotion. It looks like Julia promotes the
Float64 when you make that array. Try adding an
Thanks for your solution as well!
Yes, this is what @pdeffebach suggested, which I marked as the answer.
Sorry, got code and error messages messed up here. Will delete post.