enter image description here

As you can see from the picture, I want to change the keys names of the list. There are 14314 keys names, but they are all mess, I want to change it with a list of continuous numbers like Range[14314]. But I don't know how to do it.


1 Answer 1


As an example, we'll use the built-in Titanic dataset

f = ExampleData[{"Dataset", "Titanic"}][GroupBy["class"]];

A Dataset can be converted to an an Association/List form by using the Normal function, e.g.,


output of Normal[f]

What you want to do is replace the keys and re-convert this into a Dataset, which is easily accomplished by:

 {values = Values@Normal[f],
  newGroups = Range@Length[f]  },
 Dataset@AssociationThread[newGroups, values]]

output of With

  • $\begingroup$ Thank you very much for helping me solve the problem Mr Schrier! $\endgroup$ Commented Mar 20, 2021 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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