I have been struggling with a pandas quest for a while now and maybe someone can shed some new light into this problem :)
Consider de following pandas dataframe, df:
Year Month Task TaskID TaskClass TaskClassID SomeValue
2019 11 A 1 X 10 6.58
2019 11 A 1 Y 20 1.58
2019 11 B 2 X 10 6.58
2019 11 B 2 Y 20 1.58
objective: group by Task in a way that each Task gets a unique TaskClass observation (which Tasks gets a TaskClass is not important for this problem, can be considered random). like this:
Year Month Task TaskID TaskClass TaskClassID SomeValue
2019 11 A 1 X 10 6.58
2019 11 B 2 Y 20 1.58
or, for instance, this:
Year Month Task TaskID TaskClass TaskClassID SomeValue
2019 11 A 1 Y 20 1.58
2019 11 B 2 X 10 6.58
other constraints the final problema will have thousands of tasks and, more important, can have more TaskClass per Task, something like this:
Year Month Task TaskID TaskClass TaskClassID SomeValue
2019 11 A 1 X 10 6.58
2019 11 A 1 Y 20 1.58
2019 11 A 1 Z 30 1.00
2019 11 A 1 W 40 0.25
2019 11 B 2 X 10 6.58
2019 11 B 2 Y 20 1.58
2019 11 B 2 Z 30 1.00
2019 11 B 2 W 40 0.25
Thank you all, in advance.