Binary numpy array to list of integers?

前端 未结 5 1380
挽巷
挽巷 2020-11-27 07:08

I have a binary array, and I would like to convert it into a list of integers, where each int is a row of the array.

For example:

from numpy import *         


        
5条回答
  •  清歌不尽
    2020-11-27 08:10

    I once asked a similar question here. Here was my answer, adapted for your question:

    def bool2int(x):
        y = 0
        for i,j in enumerate(x):
            y += j<

提交回复
热议问题