Message Boards Message Boards

0
|
5056 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

[?] Access structured dataset?

Posted 7 years ago

The code below (and attached) creates a hierarchical dataset in which the top-level keys map to a list of associations. The intent is to be able to perform an efficient structured access to data. But my attempts to access the data result in errors. What am I doing wrong?

ri := RandomInteger[{1, 9}]

record := <|"a" -> ri, "b" -> ri, "c" -> ri|>

group[n_] := <|"k" <> n -> Table[record, {4}]|>

ds = Dataset[group /@ {"1", "2", "3"}]

enter image description here

In[6]:= ds[["k1"]]

Out[6]= Failure[Dataset, 
Association[
 "MessageTemplate" :> MessageName[Dataset, "partnotapplicable"], 
  "MessageParameters" -> Association["Type" -> TypeSystem`Vector[
TypeSystem`Assoc[
TypeSystem`Atom[String], 
TypeSystem`Vector[
TypeSystem`Struct[{"a", "b", "c"}, {
TypeSystem`Atom[Integer], 
TypeSystem`Atom[Integer], 
TypeSystem`Atom[Integer]}], 4], 1], 3], "Part" -> "k1", 
    "Symbol" -> Part]]]
Attachments:
POSTED BY: David Keith
ds[[1, "k1"]]

If you hover with your mouse over the values in the table, it will show you the syntax below it:

enter image description here

POSTED BY: Sander Huisman
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