I want to build a data frame with m column and n rows. Each rows start with 1 and increment by 1 until m.
I've tried to find a solution, but I found only this solution for the columns. I have also added a figure of a simple case.
I want to build a data frame with m column and n rows. Each rows start with 1 and increment by 1 until m.
I've tried to find a solution, but I found only this solution for the columns. I have also added a figure of a simple case.
You can use np.tile:
import numpy as np
m = 4
n = 3
out = pd.DataFrame(np.tile(np.arange(1,m), (n,1)), columns=[f'c{num}' for num in range(m-1)])
Output:
c0 c1 c2
0 1 2 3
1 1 2 3
2 1 2 3