Message Boards Message Boards

1
|
3336 Views
|
0 Replies
|
1 Total Likes
View groups...
Share
Share this post:

JoinAcross on nested association by nested key

Posted 9 years ago

I would like to join two associations on nested keys. Is this possible?

first = {<|"away" -> <|"name" -> "bob", "money" -> 10 |>, "home" -> <|"name" -> "Sue", "money" -> 15 |>|>, <|"away" -> <|"name" -> "Joe", "money" -> 20 |>, "home" -> <|"name" -> "Jane", "money" -> 25 |>|>}

second = {<|"away" -> <|"name" -> "bob", "Sex" -> "male" |>,  "home" -> <|"name" -> "Sue", "sex" -> "female"|>|>, <|"away" -> <|"name" -> "Joe", "Sex" -> "Male" |>, "home" -> <|"name" -> "Jane", "Sex" -> "Female" |>|>}

result=JoinAcross[first, second, ?? ?]

What I would like is:

result = {<|"away" -> <|"name" -> "bob", "money" -> 10, "Sex" -> "male"|>, "home" -> <|"name" -> "Sue", "money" -> 15, "sex" -> "female"|>|>, <|"away" -> <|"name" -> "Joe", "money" -> 20, "Sex" -> "Male"|>, "home" -> <|"name" -> "Jane", "money" -> 25, "Sex" -> "Female"|>|>}

It does not work on just the "away" key due to the "away" key in first and second not being exactly the same and JoinAcross[first,second,"Outer"] just yields a Join.

Is it possible to join across a nested key?

I have tried

JoinAcross[first, second, "away"]

and several variations with zero success.

Thank you.

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

Group Abstract Group Abstract