# KeyMap on a flat Dataset (i.e. Dataset@Association)

Bug introduced in 10.0.0 and fixed in 10.1
See Kuba's anwser below for the bug.

Dataset is new in 10.0.0.

How can I go from

Dataset[<|"A" -> 1, "B" -> 2, "C" -> 3|>]


to

Dataset[KeyMap[f, <|"A" -> 1, "B" -> 2, "C" -> 3|>]]


(which for some reason is not formatting), without converting the original Dataset using Normal?

Edit

Kuba: tag added since WRI confirmed that solution from my answer reveals one.

• Was fixed in 10.1 May 14, 2015 at 16:09

I'm just starting with those associations stuff but this seems to work:

 Dataset[<|"A" -> 1, "B" -> 2, "C" -> 3|>][ KeyMap[f, #] & ]


while I'm not entirely sure why this does not

Dataset[<|"A" -> 1, "B" -> 2, "C" -> 3|>][ KeyMap[f] ]


p.s. note about formatting. it is not done because f["A"] is not a string and "proper" associacion key should be a string (for querying purposes).

• It seems like a bug to me. Those should both work. Jan 23, 2015 at 23:30
• @StefanR I was going to report that but then I saw your profile. :) Or should I do this anyway?
– Kuba
Jan 23, 2015 at 23:35
• I've already notified the developers of this issue :) Jan 26, 2015 at 15:42

If the function f is undefined the result is not formatted, but if you have a defined the function it works fine:

ds = Dataset[<|"A" -> 1, "B" -> 2, "C" -> 3|>]


so

Dataset@KeyMap[f][<|"A" -> 1, "B" -> 2, "C" -> 3|>]


does not format the output, but with g[x_String] := x ~~ "1" one gets formatted output

Dataset@KeyMap[g][<|"A" -> 1, "B" -> 2, "C" -> 3|>]