I want to combine two datasets that share row keys but have different column keys. Visually, this looks like a JoinAcross on the row keys to me, but the column of row keys doesn't appear to be named. Can I perform this combination as a JoinAcross, or does it require a different function?
Also, the row keys are sometimes cumbersome--is there a way to demote them to normal rows?
Example of desired dataset combination
I have two datasets:
dsA = {<|"keyA" -> <|"key1" -> "a", "key2" -> "b"|>,
"keyB" -> <|"key1" -> "c", "key2" -> "d"|>|>} // Dataset;
dsB= {<|"keyA" -> <|"key3" -> "a", "key4" -> "b"|>,
"keyB" -> <|"key3" -> "d", "key4" -> "f"|>|>} // Dataset;
I want the join these such that I get a third dataset:
dsNew ={<|"keyA" -> <|"key1" -> "a", "key2" -> "b", "key3" -> "a",
"key4" -> "b"|>,
"keyB" -> <|"key1" -> "c", "key2" -> "d", "key3" -> "d",
"key4" -> "f"|>|>} // Dataset
I have tried JoinAcross[ dsA, dsB, Keys[dsA]]
, but this produces unclear errors.
Example of desired Key demotion
I have dsA
again. I want to "demote" its row keys, such that I get:
{<|"RowKeys" -> "keyA", "key1" -> "a", "key2" -> "b"|>,
<|"RowKeys" -> "keyB", "key1" -> "c", "key2" -> "d"|>} // Dataset