pythonnumpylist-comprehensionnumpy-dtype

Converting list of list of Int32 values to list of list of int values


I have a list of lists which contain numpy int32 values. I would like to convert all of these int32 values to regular int. The reason is because as a part of my process these values are fed into a non max suppression function later on, which won't accept int32.

Below is what the structure of what my data looks like (in regular int form). I don't know how to make a test set for int32 values... Or else I would probably have this problem figured out.

List of list of ints

test_list = [[1,2,3,4],[5,6,7,8]]

Edit: Some screenshots to help understand what my data looks like.

enter image description here enter image description here


Solution

  • This should work:

    In [167]: [[int(x) for x in sublist] for sublist in test_list]
    Out[167]: [[1, 2, 3, 4], [5, 6, 7, 8]]