Group Abstract Group Abstract

Message Boards Message Boards

1
|
8.4K Views
|
5 Replies
|
10 Total Likes
View groups...
Share
Share this post:

Turn an association into a list of lists?

Posted 9 years ago

Hi everyone,

How would I combine the keys of an association with its corresponding values to create a list of lists?

Regards,

Gregory

POSTED BY: Gregory Lypny
5 Replies
Posted 9 years ago

Hi Marco, Ming Yang, Kuba, and Christopher, Thanks for your tips. So many ways to do it!

Gregory

POSTED BY: Gregory Lypny

This here also could work:

List @@@ Normal[assoc]

Cheers,

M.

POSTED BY: Marco Thiel
Posted 9 years ago

Join[{Keys[asso[[1]]]}, Values[asso]]

enter image description here

POSTED BY: Ming Yang Zhou

If your association isn't nested:

KeyValueMap[List, asso]
POSTED BY: Kuba Podkalicki

There are probably better ways to do this, but

Partition[Riffle[Keys[testAssoc], Values[testAssoc]], 2]

seems to get the job done.

POSTED BY: Christopher Fox
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard