bikuser bikuser - 1 month ago 11
Python Question

float() argument must be a string or a number, not 'zip'

There is no problem when I run in python 2.7 but I am getting error when I run in python 3.

Is there something that I need to change in this code.

import matplotlib as mpl
poly = mpl.path.Path(zip(listx,listy))


error that I am getting is

TypeError: float() argument must be a string or a number, not 'zip'

Answer

This is because in python2 zip() returns a list of tuples, which mpl.path.Path() happily accepts. In python3, zip() returns an iterator, which you must consume. You should be able to do something like:

>>> poly = mpl.path.Path(list(zip(listx, listy)))
Comments