Pandas 从特定列生成随机数

Pandas 从特定列生成随机数,pandas,random,Pandas,Random,我有一个这样的数据集 item_id EAN Price 3434 232 34 3233 412 28 总共有54344个数据点 我想随机打印EAN中的40个值。我尝试了一些技巧,比如 df=pd.read_csv('item_desc.csv') print(df['EAN'].random.rand(40)) 但它不起作用。有人能给我推荐代码吗?你可以使用示例: df.sample(n=40) 您可以使用示例: df.sample(n=40)

我有一个这样的数据集

item_id  EAN   Price
3434     232    34
3233     412    28
总共有54344个数据点

我想随机打印EAN中的40个值。我尝试了一些技巧,比如

df=pd.read_csv('item_desc.csv')
print(df['EAN'].random.rand(40))

但它不起作用。有人能给我推荐代码吗?你可以使用
示例

df.sample(n=40)

您可以使用
示例

df.sample(n=40)