I have the following nested dataset:
ds = Dataset[
<|"x" ->
{<|"col1" -> 4.2, "col2" -> 2.5|>, <|"col1" -> 1.6,
"col2" -> 7.4|>, <|"col1" -> 7.1, "col2" -> 3.6|>}
,
"y" ->
{<|"col1" -> 9.1, "col2" -> 2.8|>, <|"col1" -> 2.7,
"col2" -> 5.4|>, <|"col1" -> 5.3, "col2" -> 0.6|>}
|>
]
How can I append a column col3
to the x
sub-dataset, so that col3=f[col1]
, as below:
Doing
ds = ds["x", All, <|#, "new" -> f[#col1]|> &]
adds the column but removes information about the "y" key.