How to break numpy array into smaller chunks/batches, then iterate through them
<p>Suppose i have this numpy array</p>

<pre><code>[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[10, 11, 12]]
</code></pre>

<p>And i want to split it in 2 batches and then iterate:</p>

<pre><code>[[1, 2, 3],      Batch 1
[4, 5, 6]]

[[7, 8, 9],      Batch 2
[10, 11, 12]]
</code></pre>

<p>What is the simplest way to do it?</p>

<p>EDIT: <strong>I'm deeply sorry i missed putting such info</strong>: Once i intend to carry on with the iteration, the original array would be destroyed due to splitting and iterating over batches. Once the batch iteration finished, i need to restart again from the first batch hence <strong>I should preserve that the original array wouldn't be destroyed</strong>. The whole idea is to be consistent with Stochastic Gradient Descent algorithms which require iterations over batches. In a typical example, I could have a 100000 iteration For loop for just 1000 batch that should be replayed again and again.</p>

<p>do like this:</p>

<pre><code>a = [[1, 2, 3],[4, 5, 6],
     [7, 8, 9],[10, 11, 12]]
b = a[0:2]
c = a[2:4]
</code></pre>

python pandas numpy