更新时间:2022-12-12 10:24:20
您可以使用 np.split
,它接受在哪里分割的索引数组:
You can use np.split
which accepts an array of indices where to split:
np.split(df, *np.where(df.BOOL == 1))
如果要在前一个数据框中包含 BOOL == 1
的行,则只需添加1到所有索引:
If you want to include the rows with BOOL == 1
to the previous data frame you can just add 1 to all the indices:
np.split(df, np.where(df.BOOL == 1)[0] + 1)