1test.loc[test.index.repeat(test.times)]
2
3 id times
40 a 2
50 a 2
61 b 3
71 b 3
81 b 3
92 c 1
103 d 5
113 d 5
123 d 5
133 d 5
143 d 5
1df.reindex(df.index.repeat(df.persons))
2Out[951]:
3 code . role ..1 persons
40 123 . Janitor . 3
50 123 . Janitor . 3
60 123 . Janitor . 3
71 123 . Analyst . 2
81 123 . Analyst . 2
92 321 . Vallet . 2
102 321 . Vallet . 2
113 321 . Auditor . 5
123 321 . Auditor . 5
133 321 . Auditor . 5
143 321 . Auditor . 5
153 321 . Auditor . 5
16