Have you tested this code? Shouldn't this be the following instead?
```
if ts in merged_raw.keys()
```