You can probably do:

```
grouping = df[column][distance_matrix.ids]
if grouping != grouping.dropna(how='all'):
    raise ValueError()
```

`dropna(how=all)` removes series (rows) that all values are `nan`