Add a column of ints to a DataFrame of strings

How to add an int column to a DataFrame of strings?

d = DataFrames.DataFrame([["hello", "world"]], [:strs])
d[:num] = [1,2]

gives an error:

MethodError: Cannot convert an object of type Int64 to an object of type String
This may have arisen from a call to the constructor String(…),
since type constructors fall back to convert methods.

But this works:

d[:num] = ["a","b"]

I thought columns of DataFrame need not have the same type. should perhaps be Vector{Any}.

1 Like

I made a PR that should fix this but not sure if it has performance problems: