Pandas loop di atas potongan baris
# credit to Stack Overflow user in the source link
import numpy as np
import pandas as pd
data = pd.DataFrame(np.random.rand(10, 3))
for chunk in np.array_split(data, 5):
# this assert may not be needed depending on your application
# left here anyway because it is in the original answer
assert len(chunk) == len(data) / 5, "This assert may fail for the last chunk if data lenght isn't divisible by 5"
# do your stuff with each chunk
wolf-like_hunter