A dataset can be created in at least two ways: first, from a list of associations, second, from an association of associations (I know that it is also possible to create it as a list of list and an association of lists, but these last two cases are not relevant).
1. This is a list of associations.
ds = Dataset@{
<|"nombre" -> "Aileen Agüero García", "edad" -> 25,"licenciatura" -> "Economía",
"universidad" -> "PUCP"|>,
<|"nombre" -> "Alvaro Gálvez Pasco","edad" -> 45, "licenciatura" -> "Ciencia política",
"universidad" -> "PUCP"|>,
<|"nombre" -> "Gastón Zapata ", "edad" -> 55,"licenciatura" -> "Antropología",
"universidad" -> "PUCP"|>,
<|"nombre" -> "Jose Velasco", "edad" -> 55,"licenciatura" -> "Economía", "universidad"->
"PUCP"|>
};
and the dataset is:
If I want to add a column I do the following:
(* Agregar una columna con distintos valores a un dataset *)
col1 = {1, 2, 3, 4}; (*se crea una lista de valores*)
nuevo = Dataset[AssociationThread["ID" -> #] & /@col1];
Join[nuevo, ds, 2] (*finalmente se unen los dos datasets usando el nivel
de especificación 2*)
And the output is:
2. Now, if I have an association of associations:
baseDeDatos = <|
"Registro1" -> <|"Nombre" -> "Juan", "Edad" -> 25,"Ciudad" -> "Madrid"|>,
"Registro2" -> <|"Nombre" -> "Maria", "Edad" -> 30,"Ciudad" -> "Barcelona"|>,
"Registro3" -> <|"Nombre" -> "Pedro", "Edad" -> 22,"Ciudad" -> "Valencia"|>|>
I don't know how to add a column to it. For example, I have tried with the following code:
ds2[All, Append[{"Estado civil" -> "Soltero",
"Estado civil" -> "Casado", "Estado civil" -> "Viudo"}]]
But there is an error in the output. Please help me!