I have a very long list I'm trying to convert as fast as possible.
Currently I'm doing the following which is very fast compared to a 1 by 1 conversion:
alist = [1,2,3,4, ... 100000]
list_with_unit = alist * ureg('meter')
list_converted = list_with_unit.to(ureg('feet'))
The problem is that if alist
contains a None
value I will get:
TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'
Has anybody an idea how to resolve this issue so that for None values I get a None returned?