Dear all, I would like to create a dataset like the one below (dt). I tried to do something but it did not work.
dt = <|"Course1" -> {<|"year" -> 2020, "students" -> 55|>, <|
"year" -> 2021, "students" -> 40|>},
"Course2" -> {<|"year" -> 2020, "students" -> 22|>, <|
"year" -> 2021, "students" -> 38|>},
"Course3" -> {<|"year" -> 2020, "students" -> 68|>, <|
"year" -> 2021, "students" -> 50|>}|>
(*This is the original list*)
member = {{"Course1", 2020,
55}, {"Course1", 2021, 40}, {"Course2", 2020, 22}, {"Course2",
2021, 38}, {"Course3", 2020, 68}, {"Course3", 2021, 50}}
(*I tried to do this*)
rw = {"Course1", "Course2", "Course3"}
cl = {"year", "students"}
v1 = {{2020, 55}, {2021, 40}, {2020, 22}, {2021, 38}, {2020,
68}, {2021, 50}}
dt = AssociationThread[
rw -> # &[AssociationThread[cl -> #] & /@ v1]];
(*Unfortunately this approach does not work.*)
Do you have any suggestion? Thank you :)