3

This is probably quite simple, but I'm new to pandas. I need to repeat a dataframe n times. My current dataframe looks like:

df =

0    0
1    60
2    300
3    320

For example, for n=3, my desired output is:

new_df =

0    0
1    60
2    300
3    320
4    0
5    60
6    300
7    320
8    0
9    60
10   300
11   320

1 Answers1

4

Use:

N = 3
df = pd.concat([df] * N, ignore_index=True)
print (df)
    col
0     0
1    60
2   300
3   320
4     0
5    60
6   300
7   320
8     0
9    60
10  300
11  320
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252