Starting from member
(your original list):
dt=GroupBy[member, First->Rest, Map[AssociationThread[{"year","students"}->#]&,#]&]
or even a little bit shorter using the operator form of Map
dt=GroupBy[member, First->Rest, Map[AssociationThread[{"year","students"}->#]&]]
return what you wanted:
<|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|>}|>
(To understand better how it works, look of course at the syntax and examples in the docs for GroupBy
and also you can proceed step by step and see what is going : GroupBy[member, First]
, then GroupBy[member, First->Last]
, ...]