how to create a dataframe by repeating series multiple times?

pandas, python

Solution

Use concat:

In [57]:

s = pd.Series(arange(10))
s
Out[57]:
0    0
1    1
2    2
3    3
4    4
5    5
6    6
7    7
8    8
9    9
dtype: int32
In [59]:

pd.concat([s] * 10, axis=1)

Out[59]:
   0  1  2  3  4  5  6  7  8  9
0  0  0  0  0  0  0  0  0  0  0
1  1  1  1  1  1  1  1  1  1  1
2  2  2  2  2  2  2  2  2  2  2
3  3  3  3  3  3  3  3  3  3  3
4  4  4  4  4  4  4  4  4  4  4
5  5  5  5  5  5  5  5  5  5  5
6  6  6  6  6  6  6  6  6  6  6
7  7  7  7  7  7  7  7  7  7  7
8  8  8  8  8  8  8  8  8  8  8
9  9  9  9  9  9  9  9  9  9  9

If you want to append as rows then remove the `axis=1` param.

Problem

Is there any function like the following to create a dataframe with ten columns of Series s? ``` df = pd.DataFrame(s, 10) ``` Thank you!

Original source