Ok ,I have Int

Jcodes = Int64[d[j] for j in J];

Paul

W dniu 2014-12-04 o 19:54, paul analyst pisze:
I cant convert Any to Int
Jcodes is ok byt is Any , not Int64
julia> Jcodes
1546654-element Array{Any,1}:
     1
     2

julia> convert(Jcodes,Int64)
ERROR: `convert` has no method matching convert(::Array{Any,1}, ::Type{Int64})

Paul


W dniu czwartek, 4 grudnia 2014 19:33:13 UTC+1 użytkownik paul analyst napisał:

    Works very fast ,THX
    Paul

    W dniu czwartek, 4 grudnia 2014 19:03:07 UTC+1 użytkownik Steven
    G. Johnson napisał:

        It sounds like you have an array J and you want to map each
        element of J to a unique integer in 1:N for N as small as
        possible?  This will do it:

            d = (Int=>eltype(J))[j => i for (i,j) in enumerate(unique(J))]

            Jcodes = [d[j] for j in J]

        Here, d is a dictionary mapping integers in 1:N to the
        corresponding values in J, and Jcodes is the "re-coded" array.


Reply via email to