I ran into this strange behavior and I’m not sure if it’s a problem with DataFrames or my interpretation with how it works.
When i generate my dataframe with an integer array and a float array, i get two float columns. But if i generate my dataframe with an integer array, float array and string array, i get an integer, float and string column.
Dataframes changes the type of data it assigned to the first column!
I’m still investigating, but I’m wondering if someone understands this behavior.
Thanks,
julia> x=[1,2,3,4,5]
5-element Array{Int64,1}:
1
2
3
4
5
julia> df = DataFrame([x,[1.0,2.0,3.0,4.0,5.0]], [:A, :B])
5×2 DataFrame
¦ Row ¦ A ¦ B ¦
¦ ¦ Float64 ¦ Float64 ¦
+-----+---------+---------¦
¦ 1 ¦ 1.0 ¦ 1.0 ¦
¦ 2 ¦ 2.0 ¦ 2.0 ¦
¦ 3 ¦ 3.0 ¦ 3.0 ¦
¦ 4 ¦ 4.0 ¦ 4.0 ¦
¦ 5 ¦ 5.0 ¦ 5.0 ¦
df = DataFrame([x,[1.0,2.0,3.0,4.0,5.0],["1","2","3","4","5"]], [:A, :B, :C])
5×3 DataFrame
¦ Row ¦ A ¦ B ¦ C ¦
¦ ¦ Int64 ¦ Float64 ¦ String ¦
+-----+-------+---------+--------¦
¦ 1 ¦ 1 ¦ 1.0 ¦ 1 ¦
¦ 2 ¦ 2 ¦ 2.0 ¦ 2 ¦
¦ 3 ¦ 3 ¦ 3.0 ¦ 3 ¦
¦ 4 ¦ 4 ¦ 4.0 ¦ 4 ¦
¦ 5 ¦ 5 ¦ 5.0 ¦ 5 ¦