pandas 模拟生成数据集的快速方法
快速生成一个DataFrame的方法:
#模拟生成数据集的方法 import pandas as pd import numpy as np boolean=[True,False] gender=['男','女'] color=['green','blue','yellow'] data=pd.DataFrame({'height':np.random.randint(150,190,100), 'weight':np.random.randint(40,90,100), 'smoker':[boolean[x] for x in np.random.randint(0,2,100)], 'gender':[gender[x] for x in np.random.randint(0,2,100)], 'age':np.random.randint(15,90,100), 'color':[color[x] for x in np.random.randint(0,len(color),100)]})