Correction:
arr1=[[19],[29],[ 0],[11],[ 1],[86],[90],[28],[23],[31],[39],[96],[82],[17],[71],[39],[ 8],[97]]
d is:
{9: 0, 19: 1, 29: 2, 39: 3, 49: 4, 59: 5, 69: 6, 79: 7, 89: 8, 99: 9}
The error, with full traceback, is:
Traceback (most recent call last):
File "stack53618793.py", line 8, in <module>
arr2 = np.vectorize(d.get)(arr1)
File "/usr/local/lib/python3.6/dist-packages/numpy/lib/function_base.py", line 1972, in __call__
return self._vectorize_call(func=func, args=vargs)
File "/usr/local/lib/python3.6/dist-packages/numpy/lib/function_base.py", line 2051, in _vectorize_call
res = array(outputs, copy=False, subok=True, dtype=otypes[0])
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
With n=8 d is {8: 0, 18: 1, 28: 2, 38: 3, 48: 4, 58: 5, 68: 6, 78: 7, 88: 8, 98: 9}. arr2 has a lot of None because that's the default for get.
vectorize performs a test calculation with the first element of arr1, and uses the result to set the return dtype.
With n=8, get(19) returns None, so the return dtype is set to object.
With n=9, get(19) returns integer 1 (it's in d), so the return dtype is int. That produces an error when another get returns None.
One fix is to set the otypes.
arr2 = np.vectorize(d.get, otypes=[object])(arr1)
Another possibility is to replace get with a `get(
arr2 = np.vectorize(lambda x: d.get(x,10))(arr1)
Then you don't need the None replacement step.
This vectorized get is probably not the fastest way of doing this replacement. But if you do use vectorize you need to watch out for traps like this automatic otypes.
When you ask about an error, you should include the full traceback, or at least enough so we know exactly where the error occurs. It wasn't obvious to me until I ran the test case.
np.putmask. Can you put a sample of your original array and the output you want?[[19] [29] [ 0] [11] [ 1] [86] [90] [28] [23] [31] [39] [96] [82] [17] [71] [39] [ 8] [97]...output[[ 1] [ 2] [10] [10] [10] [10] [10] [10] [10] [10] [ 3] [10] [10] [10] [10] [ 3] [10] [10]....arr1, so that anyone can run your code and reproduce your error.