Repository: arviz-devs/arviz

Issue:
Summary shows coordinates without dims as data_vars
**Describe the bug**
xarray allows to include coordinates without dimensions, which are treated incorrectly as variables by summary when converting to dataframe.

**To Reproduce**
```python
import arviz as az
import pymc3 as pm
import numpy as np

vals=np.array([[1,2,3], [4,5,6]])
with pm.Model() as m:
    sd = pm.HalfNormal("sd", sigma=10)
    mu = pm.Normal("mu", mu=0, sd=sd, shape=(2, 1))
    y = pm.Normal("y", mu=mu, sd=1, observed=vals)
    trace=pm.sample(draws=100, tune=100)

data = az.from_pymc3(trace=trace)
print(az.summary(data))

data.posterior = data.posterior.squeeze()
print(az.summary(data))
```

which prints:

```
          mean     sd  hpd_3%  hpd_97%  ...  ess_sd  ess_bulk  ess_tail  r_hat
mu[0,0]  1.968  0.562   0.838    2.935  ...   240.0     247.0     282.0   1.01
mu[1,0]  4.941  0.512   3.962    5.843  ...   629.0     620.0     350.0   1.01
sd       6.480  3.559   1.925   13.606  ...   178.0     228.0     207.0   1.01

[3 rows x 11 columns]
           mean     sd  hpd_3%  hpd_97%  ...  ess_sd  ess_bulk  ess_tail  r_hat
mu[0]     1.968  0.562   0.838    2.935  ...   240.0     247.0     282.0   1.01
mu[1]     4.941  0.512   3.962    5.843  ...   629.0     620.0     350.0   1.01
mu_dim_1  0.000  0.000   0.000    0.000  ...     0.0       0.0       0.0   0.00
sd        6.480  3.559   1.925   13.606  ...   178.0     228.0     207.0   1.01

[4 rows x 11 columns]
```

**Expected behavior**
Both datasets yield the same summary dataframe.

**Additional context**
Working on development version ArviZ.

Summary shows coordinates without dims as data_vars
**Describe the bug**
xarray allows to include coordinates without dimensions, which are treated incorrectly as variables by summary when converting to dataframe.

**To Reproduce**
```python
import arviz as az
import pymc3 as pm
import numpy as np

vals=np.array([[1,2,3], [4,5,6]])
with pm.Model() as m:
    sd = pm.HalfNormal("sd", sigma=10)
    mu = pm.Normal("mu", mu=0, sd=sd, shape=(2, 1))
    y = pm.Normal("y", mu=mu, sd=1, observed=vals)
    trace=pm.sample(draws=100, tune=100)

data = az.from_pymc3(trace=trace)
print(az.summary(data))

data.posterior = data.posterior.squeeze()
print(az.summary(data))
```

which prints:

```
          mean     sd  hpd_3%  hpd_97%  ...  ess_sd  ess_bulk  ess_tail  r_hat
mu[0,0]  1.968  0.562   0.838    2.935  ...   240.0     247.0     282.0   1.01
mu[1,0]  4.941  0.512   3.962    5.843  ...   629.0     620.0     350.0   1.01
sd       6.480  3.559   1.925   13.606  ...   178.0     228.0     207.0   1.01

[3 rows x 11 columns]
           mean     sd  hpd_3%  hpd_97%  ...  ess_sd  ess_bulk  ess_tail  r_hat
mu[0]     1.968  0.562   0.838    2.935  ...   240.0     247.0     282.0   1.01
mu[1]     4.941  0.512   3.962    5.843  ...   629.0     620.0     350.0   1.01
mu_dim_1  0.000  0.000   0.000    0.000  ...     0.0       0.0       0.0   0.00
sd        6.480  3.559   1.925   13.606  ...   178.0     228.0     207.0   1.01

[4 rows x 11 columns]
```

**Expected behavior**
Both datasets yield the same summary dataframe.

**Additional context**
Working on development version ArviZ.



Discussion:

Resolving patch:
diff --git a/arviz/stats/stats.py b/arviz/stats/stats.py
--- a/arviz/stats/stats.py
+++ b/arviz/stats/stats.py
@@ -976,7 +976,9 @@ def summary(
         )
     metrics.extend(extra_metrics)
     metric_names.extend(extra_metric_names)
-    joined = xr.concat(metrics, dim="metric").assign_coords(metric=metric_names)
+    joined = (
+        xr.concat(metrics, dim="metric").assign_coords(metric=metric_names).reset_coords(drop=True)
+    )
 
     if fmt.lower() == "wide":
         dfs = []


Test patch: