Append to Numpy Using a For Loop
<p>I am working on a Python script that takes live streaming data and appends it to a numpy array. However I noticed that if I append to four different arrays one by one it works. For example:</p>

<pre><code>openBidArray = np.append(openBidArray, bidPrice)
highBidArray = np.append(highBidArray, bidPrice)
lowBidArray = np.append(lowBidArray, bidPrice)
closeBidArray = np.append(closeBidArray, bidPrice)
</code></pre>

<p>However If I do the following it does not work:</p>

<pre><code>arrays = ["openBidArray", "highBidArray", "lowBidArray", "closeBidArray"]

for array in arrays:
    array = np.append(array, bidPrice)
</code></pre>

<p>Any idea on why that is?</p>

<p>In your second example, you have strings, not np.array objects. You are trying to append a number(?) to a string.</p>

<p>The string "openBidArray" doesn't hold any link to an array called <code>openBidArray</code>.</p>

python arrays numpy