for offset, window in rolling(df, 100, 100):
# | | | |
# | The current chunk. | How many rows to step at a time.
# The current offset index. How many rows in each chunk.
# your code here
pass
还有一个更简单的想法:
def chunk(seq, size):
return (seq[pos:pos + size] for pos in range(0, len(seq), size))
Usage:
for df_chunk in chunk(df, 100):
# |
# The chunk size
# your code here