How do I take obs_id from an Arviz idata object and turn that into a dataframe?

Hello,

I have an arviz data set with an obs_id of a product code and obs_id of the month-year that product was sold. I’d like to pull the mean of the posterior predictive samples for reach month-year/product combination.

I know I can get the mean of the posterior predictive samples by doing ppc.mean(dim=['chain, 'draw']. I can see the mean for each of the obs_id. How would I pull the obs_ids out with the mean values as a three column dataframe?

I figured this out.

x = trace_9.posterior_predictive.predicted_eaches.mean(dim=['chain', 'draw']).to_dataframe()
1 Like