Convert entries of an array to a list
<p>I have numpy arrays which entries consists of either zeros or ones. For example <code>A = [ 0.  0.  0.  0.]</code>, <code>B= [ 0.  0.  0.  1.]</code>, <code>C= [ 0.  0.  1.  0.]</code> Now I want to convert them into a list: <code>L =['0000', '0001', '0010']</code>. Is there an easy way to do it?</p>

<p>You need to cast to <code>str(int(ele))</code> and then join:</p>

<pre><code>["".join([str(int(f)) for f in arr]) for arr in (A, B, C)]
</code></pre>

<p>Or since you seem to have numpy arrays:</p>

<pre><code>["".join(map(str, arr.astype(int))) for arr in (A,B,C)]
</code></pre>

<p>Or use astype twice:</p>

<pre><code>["".join(arr.astype(int).astype(str)) for arr in (A,B,C)]
</code></pre>

python arrays list