I'm very excited about the brand new Dataset
function. I have played with it in Wolfram Cloud, and haven't figured out how can I add a new column into an existing Dataset
. Here is an example:
data={<|"col1"->1,"col2"->2|>,<|"col1"->3,"col2"->4|>,<|"col1"->5,"col2"->6|>};
ds=Dataset[data]
Now I can play with ds
columns. For example, I can easily make calculations between columns using theytheir names like:
ds[All, (#col1+#col2&)]
{3, 7, 11}
Another way is:
ds[All, <|"col3"-> (#col1+#col2&)|>]
<|col3->3,col3->7,col3->11|>
Now, how can I update ds
, to append the brand new calculated column as "col3"? I tried:
Join[ds,ds[All, <|"col3"-> (#col1+#col2&)|>],2]
without success. It would be magic if I could just do something like:
ds[All, "col3"]=ds[All, (#col1+#col2&)]
But doit does not work either.