0

I'm using numpy.

I want to repeat numbers from 0 to 10000 five times.

Let me show you a simple example below.

0
0
0
0
0
1
1
1
1
1
2
2
2
2
2
3
3
3
3
3

9999
9999
9999
9999
9999
10000
10000
10000
10000
10000

How can I do this?

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
김수환
  • 131
  • 1
  • 1
  • 7

1 Answers1

1

Use numpy.repeat with numpy.arange:

a = np.repeat(np.arange(10001), 5)
print (a)
[    0     0     0 ... 10000 10000 10000]
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252