pandas打乱数据的顺序

使用sklearn

from sklearn.utils import shuffle  
df = shuffle(df)  

或者用自带的df.sample(frac=1)
frac决定打乱的比例,例如0.3就是30%
保持索引df.sample(frac=1).reset_index(drop=True)

你可能感兴趣的:(pandas,python)