print(dating_df.head(3))
miles games ice_cream opinion 0 40920 8.326976 0.953952 3 1 14488 7.153469 1.673904 2 2 26052 1.441871 0.805124 1
dating_df.opinion.replace({1:'disliked', 2:'OK', 3:'liked'}, inplace=True)
print(dating_df.head(3))miles games ice_cream opinion 0 40920 8.326976 0.953952 liked 1 14488 7.153469 1.673904 OK 2 26052 1.441871 0.805124 disliked
in the absence of a built-in replace function, this might work:using Compat, Distributions, DataFrames, DataFramesMetamapping = @Compat.Dict(1 => "a", 2 => "b", 3=> "c")
df[:opinion] = @with df begin:opinion = [mapping[i] for i in :opinion]endthe @with isn't really necessary, you could just write:
df[:opinion] = df[:opinion] = [mapping[i] for i in df[:opinion]]
On Tuesday, January 6, 2015 12:47:23 AM UTC+1, Alexander Flyax wrote:
--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
dating_df[:opinion] = [ {1 => "bad", 2 => "OK", 3 => "good"}[i] for i in dating_df[:opinion] ]
mapping = {1 => "bad", 2 => "OK", 3 => "good"}
dating_df[:opinion] = [ mapping[i] for i in dating_df[:opinion] if i in mapping]
`convert` has no method matching convert(::Type{Int64}, ::ASCIIString)
(I am trying to say df[:col][i] = "text".)