8
$\begingroup$

I am trying to understand the structure and the use of Dataset and I came across something new to me.

First check this example:

ds1=Dataset[{
  <|"a" -> 1, "b" -> "x", "c" -> 6|>,
  <|"a" -> 2, "b" -> "y", "c" -> {2, 3}|>,
  <|"a" -> "x", "b" -> "z", "c" -> {3}|>,
  <|"a" -> 4, "b" -> "x", "c" -> {4, 5}|>,
  <|"a" -> 5, "b" -> "y", "c" -> {5, 6, 7}|>,
  <|"a" -> 6, "b" -> "z", "c" -> {}|>}]

ds2=Dataset[{
  <|"a" -> 1, "b" -> "x", "c" -> 6|>,
  <|"a" -> 2, "b" -> "y", "c" -> {2, 3}|>,
  <|"a" -> "x", "b" -> "z", "c" -> {3}|>,
  <|"a" -> 4, "b" -> "x", "c" -> {4, 5}|>,
  <|"a" -> 5, "b" -> "y", "c" -> {5, 6, 7}|>,
  <|"a" -> 6, "b" -> "z", "c" -> {}|>}]
ds1===ds2
(*False*)

When I look at the FullForm, I found that each one has different Association[Rule["ID", number] at the end of the FullForm. This number changes each time ds1 or ds2 are evaluated.

I have two questions:

1-If I have a big Dataset how can I know if they are equal or not?

2- What is Association[Rule["ID", number] and how it is used?

$\endgroup$
  • $\begingroup$ Ok. should I wait for someone to support your suggestion or I just go ahead and post separate questions? $\endgroup$ – Algohi Feb 16 '15 at 19:38
  • $\begingroup$ Thanks:) I want to search each one separately. $\endgroup$ – Algohi Feb 16 '15 at 19:48
  • $\begingroup$ They are not in the same association but in different associations in the same Dataset. $\endgroup$ – Algohi Feb 16 '15 at 19:56
  • $\begingroup$ Done. Thanks:). $\endgroup$ – Algohi Feb 16 '15 at 20:08
  • 3
    $\begingroup$ Semantically, a Dataset is intended as a database table within Wolfram Language. As such, it should not be common practice to ask whether two Datasets are the equal, much like one wouldn't ask whether two database tables are the equal. $\endgroup$ – Shredderroy Aug 14 '18 at 16:20
3
$\begingroup$

I'm interested in your question because I've never thought to look at the full form of a Dataset before! As such, I can't really say what the internal ID might be for in the Dataset object, except to say that SameQ likely fails because Dataset is likely treated internally like an Object. Each instantiation is distinct.

However, you can test for sameness of the data within a Dataset like so:

SameQ @@ (Normal /@ {ds1, ds2})

I hope at least that helps!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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