3
$\begingroup$

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|>]

enter image description here

to

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

enter image description here

(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.

$\endgroup$
  • $\begingroup$ Was fixed in 10.1 $\endgroup$ – Gordon Coale May 14 '15 at 16:09
2
$\begingroup$

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).

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

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|>]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.