Reputation: 55
I am trying to add a new column Y to a dataframe of type Float64
using another column Z of integer and an array X of type Array{Float64,1}
.
When I run the command:
df[:Y] = map(z->X[z],df[:Z])
I get that that type of df[:X]
is Any
.
How can I change the type of df[:Y]
to Float?
Example:
df = DataFrame( Z = @data([1, 2, 3, 4, 5]) )
X = [1.1 2.2 3.3 4.4 5.5]
df[:Y] = map(z->X[z],df[:Z])
then typeof(df[:Y])
returns DataArrays.DataArray{Any,1}
.
Upvotes: 3
Views: 1485
Reputation: 4181
df[:Y] = convert(DataArray{Float64,1}, map(z->X[z],df[:Z]))
Like that, or were you looking for something more?
Upvotes: 2