Batch Iterating in Pandas


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


Revision #3
Created 2022-11-08 11:10:04 UTC by James
Updated 2024-01-21 14:54:01 UTC by James