0

I have the following dataframe

 Code 
   1
   3
   4
   5

I want to repeat each code value 5 times so that output is:

 Code 
   1
   1
   1
   1
   1
   3
   3
   3
   3
   3
   4
   4
   4
   4
   4
   5
   5
   5
   5
   5

np.repeat does not seem to work on dataframes

tj judge
  • 626
  • 3
  • 17

1 Answers1

1

You can repeat the index:

df.loc[df.index.repeat(5)]
mozway
  • 194,879
  • 13
  • 39
  • 75