>df = DataFrame(columns=('lib', 'qty1', 'qty2'))
for i in range(5):
df.loc[i] = [randint(-1,1) for n in range(3)]
>print(df)
lib qty1 qty2
0 0 0 -1
1 -1 -1 1
2 1 -1 1
3 0 0 0
4 1 -1 -1
[5 rows x 3 columns]
https://ask.helplib.com/303504点击打开链接
本文介绍了一种使用Python Pandas库生成包含随机整数的DataFrame的方法。通过循环填充DataFrame,并展示了最终生成的数据表格。
1014

被折叠的 条评论
为什么被折叠?



