I have an Association with lots of key-value pairs. The values are integer numbers from a finite set. I'd like to group all the keys that have a certain number as value, and make a table with values (numbers) on top row (one per column) and each key set under each corresponding value.

I tried with GroupBy, with no success.

Edit Example:

<|key1->2, key2->4, key3->4, key4->2, key5->7, key6->4|>

Output: a table like this:

|  2     |   4     |  7      |
| key1   | key2    | key5    |
| key4   | key3    |         |
|        | key6    |         |

1 Answer 1

GroupBy[a, Identity, Keys] // Dataset

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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