# How to access Dataset's metadata

A Dataset object has internal metadata. For example, let

ds = Dataset[{<|"a" -> 1, "b" -> "x", "c" -> {1}|>}];


Then, after re-formatting for legibility,

FullForm[ds]


shows this:

Dataset[
List[
Association[
Rule["a",1],
Rule["b","x"],
Rule["c",List[1]]
]
],
TypeSystemVector[
TypeSystemStruct[
List["a","b","c"],
List[
TypeSystemAtom[Integer],
TypeSystemAtom[String],
TypeSystemVector[
TypeSystemAtom[Integer],
1
]
]
],
1
],
Association[Rule["ID",204779820583110]]
]


One can't, however, access the parts of this expression in the usual way (i.e. using Part). For example, ds[[3]] evaluates to

Also, one can't change the head of the Dataset object the usual way (i.e. using Apply): Head[List @@ ds] evaluates to Dataset, not List.

Questions:

1. How can one access the internal parts of a Dataset object programmatically?
2. What other general Mathematica rules fail to hold when it comes to Dataset objects?
3. Where in the Mathematica documentation are the answers to the previous two questions to be found?

• ds is AtomQ. Just try AtomQ@ds. ds[[3]] is like (1/2)[[1]]. (FullForm[1/2] is Rational[1, 2]). – Karsten 7. May 16 '16 at 19:52
• There should be some useful functions for this job in Needs["TypeSystem"]; Names["TypeSystem*"] and Needs["Dataset"]; Names["Dataset*"]. Most of these are probably undocumented. – Karsten 7. May 16 '16 at 20:01

Starting with the same Dataset as m_goldberg in his answer

ds = Dataset[{<|"a" -> 1, "b" -> "x", "c" -> {1/2}|>,
<|"a" -> 2, "b" -> "y", "c" -> {"a", {}, 1/2}|>}]


The same information can be extracted using

Needs["Dataset"]
GetData@ds
GetRawData@ds
GetType@ds
ToDatasetHandle@ds


One can get all these information at once using

DatasetPart@ds


• The DatasetHandle or "ID" is unique to each Dataset, therefore everyone will have a different one and it'll change after reevaluating the definition of ds. – Karsten 7. May 16 '16 at 23:55

This is what I able to extract.

ds =
Dataset[
{<|"a" -> 1, "b" -> "x", "c" -> {1/2}|>,
<|"a" -> 2, "b" -> "y", "c" -> {"a", {}, 1/2}|>}]


{data, types, id} =
ToExpression[StringReplace[ToString @ FullForm[ds], "Dataset" -> "List"]];

Dataset[data]


types


which has the raw input form

TypeSystemVector[
TypeSystemStruct[
{"a", "b", "c"},
{TypeSystemAtom[Integer], TypeSystemAtom[String],
TypeSystemVector[TypeSystemAnyType, TypeSystemAnyLength]}],
2]

id


<|"ID" -> 125700882739855|>

I think it is interesting that code editor has special formatting for the type metadata.

• The special formatting for the type metadata comes with a nice Tooltip and CellPrint after clicking feature. – Karsten 7. May 17 '16 at 0:07