How to Process Data in Batches in Python