# Batch Iterating in Pandas

```python

BATCH_SIZE=32

for k,grp in df.groupby(np.arange(len(df))//BATCH_SIZE):
    # grp is a tiny dataframe BATCH_SIZE rows long
    print(k,grp)
    

```

## References

- [python - How to iterate over consecutive chunks of Pandas dataframe efficiently - Stack Overflow](https://stackoverflow.com/questions/25699439/how-to-iterate-over-consecutive-chunks-of-pandas-dataframe-efficiently)