Categories in another column, how to use dynamically?

The missing usage of the values column was a typo when I was typing the example code. I have corrected the question. I also noticed I was calculating the diffs incorrectly and adjusted that.

At the moment, I would be looking for the differences in means between the label categories.

What I have there runs, but it feels like there is a better way to write it. And maybe a better way to scale it. If I had another column of new categories, say, “country,” I might want to compare across countries and labels without having to write a number of lines equal to

df.countries.nunqiue() * df.labels.nunique()

Times however many lines the model definition is.

I suspect that I need to be using the shape kwarg in the model definition, but I don’t yet understand what exactly shape does and when to use it.