Replace self.toList(x) with x.tolist()