如何按行将数据拆分为小数据集?

How can I split a data into small datasets by rows?

我有一个 60000x32 的数据集。我想这样拆分 第一次拆分= (0:126,:) 秒=(126:252,:) ` 第三 = (252:378,:) .. ..直到最后...

应该是这个顺序。每个拆分的大小都必须为 126x32。我该怎么做?

尝试这样的事情

def segment_data(data, n_rows):
    """
    :param data: dataframe with 60000 rows and 32 features
    :param n_rows: number of rows in each segment
    :return: list of dataframes with 126 rows and 32 features
    """
    segments = []
    for i in range(0, len(data), n_rows):
        segment = data.iloc[i:i + n_rows, :]
        segments.append(segment)
    return segments


segments = segment_data(data, 126)