【发布时间】:2015-06-17 01:23:21
【问题描述】:
我有以下数据框:
Col1 Col2 Col3 Type
0 1 2 3 1
1 4 5 6 1
...
20 7 8 9 2
21 10 11 12 2
...
45 13 14 15 3
46 16 17 18 3
...
DataFrame 是从 csv 文件中读取的。所有Type 1 的行都在最上面,然后是Type 2 的行,然后是Type 3 的行,等等。
我想打乱 DataFrame 行的顺序,以便混合所有 Type。可能的结果是:
Col1 Col2 Col3 Type
0 7 8 9 2
1 13 14 15 3
...
20 1 2 3 1
21 10 11 12 2
...
45 4 5 6 1
46 16 17 18 3
...
我怎样才能做到这一点?
【问题讨论】:
标签: python pandas dataframe permutation shuffle