Display of coords or categories names in output summary az.sunmmary()

df_penguins=pd.read_csv(r’https://raw.githubusercontent.com/BayesianModelingandComputationInPython/BookCode_Edition1/main/data/penguins.csv’)
#df_penguins.to_csv(‘penguins.csv’)

df=df_penguins.dropna(how = ‘any’).reset_index(drop=True)

df_s=df.sample(50).reset_index()
data=df_s[‘body_mass_g’]

species = pd.Categorical(df_s[“species”]) #with pm.Model(coords={“species”: [‘Adelie’, ‘Chinstrap’, ‘Gentoo’]})

with pm.Model(coords={‘species’:species.categories}) as model_penguin_mass_all_species:
μ = pm.Normal(“μ”, 4000, 3000, dims=‘species’)
σ = pm.HalfStudentT(“σ”, 100, 2000, dims=‘species’)
y = pm.Normal(“y”,mu=μ[species.codes],sigma=σ[species.codes],observed=data)

difference_10=pm.Deterministic('μ[1]-μ[0]',μ[1]-μ[0])

idata_all = pm.sample(chains=2)
idata_all.extend(pm.sample_prior_predictive())
idata_all.extend(pm.sample_posterior_predictive(idata_all))

display(az.summary(idata_all))
az.plot_posterior(idata_all)
In az.summary(idata_all) it would be very nice if μ[1]-μ[0] was displayed as μ[Chinstrap]-μ[Adelie] ie with the name of the group, or category which is the penguin species in this case. all the other entries in az.summary are labelled with the species names except the deterministic variable; is there an easy way to fix this? Thanking you, declan

The first argument of Deterministic is the name you give the variable. In your case, you are naming it “μ[1]-μ[0]” which is why ArviZ uses that name. The easiest way to fix this would be to use the name you want here directly.