In this tutorial, we will introduce you how to fix TypeError: int() argument must be a string, a bytes-like object or a number, not ‘map’ in python.
Look at this example code:
import numpy as np usrs = [] usr = map(lambda x: x*x, [1,2,3]) usrs.append(np.asarray(usr, dtype=np.int32))
Run this code, you will get this error:
How to fix this typeerror?
In python 3.x, you can use a map to create a list.
usrs = [] usr = list(map(lambda x: x*x, [1,2,3])) usrs.append(np.asarray(usr, dtype=np.int32)) print(usrs)
Run this code, you will get:
[array([1, 4, 9])]
This error is fixed.