Can't get Append to append a record (association) to a dataset
This is interesting:
If you replace the symbol y
with the string "y"
, Append
works fine.
Append[ds, <|"a" -> 5, "b" -> "y"|>]
Also, if you start out with Symbol
s, then it works fine:
ds = Dataset[{<|"a" -> 1, "b" -> x|>, <|"a" -> 2, "b" -> y|>, <|
"a" -> 3, "b" -> z|>, <|"a" -> 4, "b" -> x|>}]
Then:
Append[ds, <|"a" -> 5, "b" -> y|>]
Using the Undocumented second argument we can force the Dataset
on creation to expect AnyType
of type:
Needs["TypeSystem`"];
dst = Dataset[{<|"a" -> 1, "b" -> "x"|>, <|"a" -> 2, "b" -> "y"|>, <|
"a" -> 3, "b" -> "z"|>, <|"a" -> 4, "b" -> "x"|>},
Vector[Struct[{"a", "b"}, {Atom[Integer], AnyType}]]]
Now Append
works even if we feed it a Symbol
instead of a String
:
Append[dst, <|"a" -> 5, "b" -> y|>]