I think that you should do:

```
xvalues = getattr(xvalues,'values',xvalues)
```

(and same for yvalues)

this will guaranteee that they are ndarrays (and not series/index)