pandas repeat rows n times

Solutions on MaxInterview for pandas repeat rows n times by the best coders in the world

showing results for - "pandas repeat rows n times"
Esme
05 Jul 2017
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
Antonin
19 Nov 2017
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
queries leading to this page
create a column with rows that repeat a number of times in pandarepeat row in pandas dataframe repeat rows python pandas more repeat rowspython repeat value in rowrepeat for each row pandaspandas repeat row n timesrepeat row n times pythonpandas copy row of dataframe n timesfor every specific row pandaspandas repeat cell n timespython pandas get more repeat rowspandas repeat rowpandas replicate row n timespandas repeat value repeat value pandaspandas duplicate rows n timesrepeat a row in pandaspandas repeat rows n timesdataframe python repeat for each rowrepeat row of pandashow to repeat rows in a dataframe based on a quantitypandas duplicate each row n timesrepeat row of dataframepandas repeat value in columnpython pandas repeat rows untilrepeat rows pandas dataframepandas repeat value every rowr dataframe repeat rowsrepeat column values pandasrepeat rows in pandasrepeat rows pandasrepeat row in dataframe pandaspandas repeat function for every n rowexcel repeat rows a specified number of times in python pandaspandas repeat each row n timespandas 28duplicate rows n times 29pandas repeat rows n times dynamicallypandas repeat rowspython dataframe repeat rows n timeshow to repeat rows in dataframepandas repeat list values in columnrepeat rows n times in pythonrepeat a row n times by col pandascopy n times the same row in pandasdataframe repeat row n timesrepeat data in rows pandashow to repeat rows in dataframe pythonpython repeat character n timespandas repeat rows n times