Change dataset key name
We can explicitly construct a new association with key names of our choosing:
dataset[All, <| "a" -> "a", "h" -> "b", "c" -> "c" |>]
Alternatively, a function could be applied to the keys:
dataset[All, KeyMap[# /. "b" -> "h" &, #] &]
Note that a bug in the V10.0.0 type system prevents us from using the operator form KeyMap[# /. "b" -> "h"&]
. (2020 Update: in more recent versions we can also write KeyMap[Replace["b" -> "h"]])
.
Or, we could explicitly add the key "h"
and drop the key "b"
, although this will re-order the keys in the resultant association:
dataset[All, <| #, "h" -> #b |> & /* KeyDrop["b"]]
Or, we could split each association into its keys and values, operate upon the keys, and then thread the results back together into an assocation:
dataset[All, AssociationThread[(Keys@# /. "b" -> "h") -> Values@#] &]
Dataset[Association /@ (Normal@Normal@dataset /. "b" -> "h")]