Message Boards Message Boards

0 Replies
0 Total Likes
View groups...
Share this post:

Dataset and JoinAcross -- Part 2

Posted 10 years ago

Yesterday I embarrassed myself by posting what turned out to be a non-issue involving Dataset and JoinAcross. I am back at it again today, but this time I think I really am on to something.

I have two Dataset objects that I have built up and which share a common attribute name, "Station". In order to illustrate here, I've done a Take[x, 1] on each of them so each only contains 1 item, but originally they were datasets in excess of 250 items. Call the pared down Datasets stations1 and distances1. The following code...

JoinAcross[stations1, distances1, {"Station", "Station"}]

...produces the following error...

enter image description here

But if I rebuild stations1 using the following code...

stations1Rebuilt = <| "Station" -> #["Station"], 
    "Latitude" -> #["Latitude"], "Longitude" -> #["Longitude"], 
    "Zone" -> #["Zone"], "Postcode" -> #["Postcode"], 
    "Line" -> #["Line"], "Usage" -> #["Usage"], 
    "AnnualCost" -> #["AnnualCost"]|> & /@ stations1

...and then JoinAcross, thus...

JoinAcross[stations1Rebuilt, distances1, {"Station", "Station"}] all works find and I get my functional, joined Dataset.

The rebuild process preserves all the attributes of stations1 in stations1Rebuilt, except 2 unneeded fields, "OS X" and "OS Y". The only difference I can see in the two is by examining them using FullForm...



enter image description here




enter image description here

Finally, if I rebuild stations1 including the two dropped attributes, "OS X" and "OS Y", and try to JoinAcross, my error returns.

This lead me to believe there must be a bug in Dataset/JoinAcross, with Dataset allowing attribute names containing spaces, but JoinAcross choking on them. But the following code...

test1 = Dataset[{<| "A" -> 10, "B C" -> 20 |>}]
test2 = Dataset[{<| "A" -> 10, "D" -> 30 |>}]
JoinAcross[test1, test2, {"A", "A"}] perfectly well.

Any thoughts, anyone?

POSTED BY: Brad Varey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract