Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The Documentation Center item, Computation with Structured Datasets, implies that Append has been extended in V10 to work with datasets. But not on my computer. (I am running on OS X)

Here is what I tried:

ds = 
  Dataset[{<|"a" -> 1, "b" -> "x"|>, <|"a" -> 2, "b" -> "y"|>, 
           <|"a" -> 3, "b" -> "z"|>, <|"a" -> 4, "b" -> "x"|>}]


Append[ds, <|"a" -> 5, "b" -> y|>]


However, insertion

Insert[ds, <|"a" -> 5, "b" -> y|>, -1]

works fine.


I don't know whether I've found a bug in Appendin combination with a dataset or whether I am misreading the documentation. Are others experiencing what I am? Or can someone explain what I did wrong?


I should have pointed out that I already knew that appending Append[ds, <|"a" -> 5, "b" -> "y"|>] worked. But why does it fail when given an unbound symbol? And why should Insert behave differently when given an unbound symbol? Is V10 attempting to enforce some kind of a type consistency on the values of associations? That would be very un-Mathematica like.

share|improve this question
It looks buggy to me given that AppendTo[ds, <|"a" -> 5, "b" -> y|>] works fine – mfvonh Jul 24 '14 at 3:52
Problem remains in version 10.0.1 – Mr.Wizard Sep 17 '14 at 11:20
up vote 14 down vote accepted

This is interesting:

If you replace the symbol y with the string "y", Append works fine.

Append[ds, <|"a" -> 5, "b" -> "y"|>]

Mathematica graphics

Also, if you start out with Symbols, then it works fine:

ds = Dataset[{<|"a" -> 1, "b" -> x|>, <|"a" -> 2, "b" -> y|>, <|
    "a" -> 3, "b" -> z|>, <|"a" -> 4, "b" -> x|>}]

Mathematica graphics


Append[ds, <|"a" -> 5, "b" -> y|>]

Mathematica graphics

Using the Undocumented second argument we can force the Dataset on creation to expect AnyType of type:


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}]]]

Mathematica graphics

Now Append works even if we feed it a Symbol instead of a String:

Append[dst, <|"a" -> 5, "b" -> y|>]

Mathematica graphics

share|improve this answer
I already knew that "y" would work, but your find concerning y working if the other values of field "b" were symbols is new to me. +1 – m_goldberg Jul 24 '14 at 5:37
Your discussion of the undocumented 2nd does indicate an intent to enforce type consistency. But the implementation seem inconsistent, since Append enforces type consistency and Insert ignores it. – m_goldberg Jul 24 '14 at 8:58
@m_goldberg. I agree. Dataset is clearly still buggy but seems to be a useful thing to have. – RunnyKine Jul 24 '14 at 9:02
@m_goldberg, I learned about it from Taliesin Beynon in this answer – RunnyKine Jul 24 '14 at 13:07
@m_goldberg This should 'coerce' the type of that column to become AnyType, rather than fail. I'll fix this, thanks for finding! – Taliesin Beynon Aug 1 '14 at 18:53

very strange.

one way around is as follows:

list = {<|"a" -> 1, "b" -> "x"|>, <|"a" -> 2, "b" -> "y"|>, <|
    "a" -> 3, "b" -> "z"|>, <|"a" -> 4, "b" -> "x"|>};
Dataset[Append[list, <|"a" -> 5, "b" -> y|>]]

If it works in this way then it should work directly with Append[ds, <|"a" -> 5, "b" -> y|>]

maybe it is a bug.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.