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))
用法:
for df_chunk in chunk(df, 100):
# |
# The chunk size
# your code here
3 回答
您可以从N计算分割数:
你可以试试这个:
用法:
还有一个更简单的想法:
用法:
BTW . 所有这些都可以在SO上找到,并进行搜索 .
计算分裂的索引:
用它们来拆分df: