This should be `ArgumentError`. Also, to reduce nesting and make it more clear, please move this check to the top of the function:

```python

if not data:
    raise ArgumentError...

...
```

Can you please also do the same in `_to_location`?