如何在不输入列表的情况下以更大的比例生成此数据框?
pip
谢谢!
答案 0 :(得分:1)
You can use np.repeat
with reshape
to get the final df you desire, this will be more efficient and less typing than your current solution:
In [17]:
df = pd.DataFrame(pd.Series(np.repeat(np.arange(5),5)).reshape(5,-1), columns=list('abcde'), index=pd.date_range(start='2000-01-01',periods=5))
df
Out[17]:
a b c d e
2000-01-01 0 0 0 0 0
2000-01-02 1 1 1 1 1
2000-01-03 2 2 2 2 2
2000-01-04 3 3 3 3 3
2000-01-05 4 4 4 4 4