Quantcast
Channel: Convert int to binary string in Python - Stack Overflow
Viewing all articles
Browse latest Browse all 74

Answer by pitfall for Python int to binary string?

$
0
0

Using numpy pack/unpackbits, they are your best friends.

Examples-------->>> a = np.array([[2], [7], [23]], dtype=np.uint8)>>> aarray([[ 2],       [ 7],       [23]], dtype=uint8)>>> b = np.unpackbits(a, axis=1)>>> barray([[0, 0, 0, 0, 0, 0, 1, 0],       [0, 0, 0, 0, 0, 1, 1, 1],       [0, 0, 0, 1, 0, 1, 1, 1]], dtype=uint8)

Viewing all articles
Browse latest Browse all 74

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>