19-pandas排序和随机抽样

import numpy as np
import pandas as pd

df=pd.DataFrame(np.arange(25).reshape(5,5))
new_order=np.random.permutation(5)#不暗中哦顺序排列
print(df.take(new_order))#take改变索引
sample=np.random.randint(0,len(df),size=2)
print(df.take(sample))#随机抽样

 

posted @ 2020-03-09 12:03  胡辣汤王子  阅读(168)  评论(0编辑  收藏  举报