Function Repository Resource:

JoinAcrossAll

Source Notebook

Join across an arbitrary number of lists of associations

Contributed by: Maximilien Tirard

ResourceFunction["JoinAcrossAll"][{list1,list2,},keyspec]

gives a list of associations obtained by joining all associations in the listi in which the values specified by keyspec match.

ResourceFunction["JoinAcrossAll"][{tab1,tab2,},keyspec]

joins Tabular objects according to keyspec.

ResourceFunction["JoinAcrossAll"][data,keyspec,joinspec]

uses joinspec to determine when to allow associations that contain missing elements to be generated.

Details

Internally, ResourceFunction["JoinAcrossAll"] uses JoinAcross.
A list of n lists or tabular objects will use n-1 calls to JoinAcross.
JoinAcrossAll joins from left to right.

Examples

Basic Examples (1) 

Join three lists of associations using a as the key:

In[1]:=
ResourceFunction["JoinAcrossAll"][{
  {<|a -> 1, b -> X|>, <|a -> 2, b -> Y|>},
  {<|a -> 1, c -> X|>, <|a -> 2, c -> Y|>},
  {<|a -> 1, d -> X|>, <|a -> 2, d -> Y|>}
  }, Key[a]]
Out[1]=

Scope (1) 

Join multiple tables from the ATP Tour:

In[2]:=
rankingsTab = Tabular[<|"RawSchema" -> <|"ColumnProperties" -> <|"World ranking" -> <|"ElementType" -> "Integer64"|>, "Name" -> <|"ElementType" -> "String"|>, "Country" -> <|"ElementType" -> TypeSpecifier["Entity"][
          "Country", "String"]|>|>, "KeyColumns" -> None, "Backend" -> "WolframKernel"|>, "BackendData" -> <|"ColumnData" -> DataStructure["ColumnTable", {{
TabularColumn[<|"Data" -> {{1, 2, 3, 4}, {}, None}, "ElementType" -> "Integer64"|>], 
TabularColumn[<|"Data" -> {{3, {0, 13, 27, 43, 54}, "Jannik SinnerCarlos AlcarazAlexander ZverevJack Draper"}, {}, None}, "ElementType" -> "String"|>], 
TabularColumn[<|"Data" -> {4, {{{3, {0, 5, 10, 17, 30}, "ItalySpainGermanyUnitedKingdom"}, {}, None}}, None}, "ElementType" -> TypeSpecifier["Entity"][
            "Country", "String"]|>]}}]|>|>]
Out[2]=
In[3]:=
servesTab = Tabular[<|"RawSchema" -> <|"ColumnProperties" -> <|"Serve ranking" -> <|"ElementType" -> "Integer64"|>, "Name" -> <|"ElementType" -> "String"|>, "Serve rating" -> <|"ElementType" -> "Real64"|>, "% Service games won" -> <|"ElementType" -> TypeSpecifier[
          "Quantity"]["Real64", "Percent"]|>, "Avg. aces/match" -> <|"ElementType" -> "Real64"|>|>, "KeyColumns" -> None, "Backend" -> "WolframKernel"|>, "BackendData" -> <|"ColumnData" -> DataStructure["ColumnTable", {{
TabularColumn[<|"Data" -> {{1, 2, 3, 4, 5}, {}, None}, "ElementType" -> "Integer64"|>], 
TabularColumn[<|"Data" -> {{3, {0, 12, 38, 55, 71, 84}, "Taylor FritzGiovanni Mpetshi PerricardMatteo BerrettiniAlexander ZverevJannik Sinner"}, {}, None}, "ElementType" -> "String"|>], 
TabularColumn[<|"Data" -> {{298.6, 297.9, 296.6, 296.6, 294.4}, {}, None}, "ElementType" -> "Real64"|>], 
TabularColumn[<|"Data" -> {5, {{{90., 89.3, 88.8, 89., 90.6}, {}, None}}, None}, "ElementType" -> TypeSpecifier["Quantity"][
            "Real64", "Percent"]|>], 
TabularColumn[<|"Data" -> {{10.5, 17., 9.8, 8.5, 7.7}, {}, None}, "ElementType" -> "Real64"|>]}}]|>|>]
Out[3]=
In[4]:=
returnsTab = Tabular[<|"RawSchema" -> <|"ColumnProperties" -> <|"Return ranking" -> <|"ElementType" -> "Integer64"|>, "Name" -> <|"ElementType" -> "String"|>, "Return rating" -> <|"ElementType" -> "Real64"|>, "% return games won" -> <|"ElementType" -> TypeSpecifier[
          "Quantity"]["Real64", "Percent"]|>|>, "KeyColumns" -> None, "Backend" -> "WolframKernel"|>, "BackendData" -> <|"ColumnData" -> DataStructure["ColumnTable", {{
TabularColumn[<|"Data" -> {{1, 2, 3, 4}, {}, None}, "ElementType" -> "Integer64"|>], 
TabularColumn[<|"Data" -> {{3, {0, 14, 28, 41, 51}, "Alex de MinaurCarlos AlcarazJannik SinnerTommy Paul"}, {}, None}, "ElementType" -> "String"|>], 
TabularColumn[<|"Data" -> {{163.1, 162.5, 160.4, 159.2}, {}, None}, "ElementType" -> "Real64"|>], 
TabularColumn[<|"Data" -> {4, {{{30., 31.1, 29.1, 28.9}, {}, None}}, None}, "ElementType" -> TypeSpecifier["Quantity"][
            "Real64", "Percent"]|>]}}]|>|>]
Out[4]=
In[5]:=
ResourceFunction[
 "JoinAcrossAll"][{rankingsTab, servesTab, returnsTab}, "Name", "Left"]
Out[5]=

Properties & Relations (3) 

JoinAcross only combines 2 items:

In[6]:=
JoinAcross[
 {<|a -> 1, b -> X|>, <|a -> 2, b -> Y|>},
 {<|a -> 1, c -> X|>, <|a -> 2, c -> Y|>},
 Key[a]]
Out[6]=

Combing three items requires nesting JoinAcross twice:

In[7]:=
JoinAcross[JoinAcross[
  {<|a -> 1, b -> X|>, <|a -> 2, b -> Y|>},
  {<|a -> 1, c -> X|>, <|a -> 2, c -> Y|>},
  Key[a]],
 {<|a -> 1, d -> X|>, <|a -> 2, d -> Y|>},
 Key[a]
 ]
Out[7]=

JoinAcrossAll does this in one step:

In[8]:=
ResourceFunction["JoinAcrossAll"][{
  {<|a -> 1, b -> X|>, <|a -> 2, b -> Y|>},
  {<|a -> 1, c -> X|>, <|a -> 2, c -> Y|>},
  {<|a -> 1, d -> X|>, <|a -> 2, d -> Y|>}
  },
 Key[a]]
Out[8]=

Publisher

Maximilien Tirard

Version History

  • 1.0.0 – 17 July 2025

Related Resources

License Information