0

i have a df1 with shape 15,1 but I need to create a new df2 of shape 270,1 with repeating rows from each row of the rows in df1 at intervals of 18 rows 15 times (18 * 15 = 270). The df1 looks like this:

              Sites
0              TULE
1        DRY LAKE I
2        PENASCAL I
3           EL CABO
4     BARTON CHAPEL
5             RUGBY
6          BARTON I
7       BLUE CREEK 
8       NEW HARVEST
9    COLORADO GREEN
10     CAYUGA RIDGE
11  BUFFALO RIDGE I
12      DESERT WIND
13       BIG HORN I
14           GROTON

My df2 should look like this in abbreviated form below and thank you,

enter image description here

user2100039
  • 1,280
  • 2
  • 16
  • 31

1 Answers1

0

I FINALLY found the answer: convert the dataframe to a series and use repeat in the form: my_series.repeat(N) and then convert back the series to a df.

user2100039
  • 1,280
  • 2
  • 16
  • 31
  • You can actually scale up with `loc` and `index repeat` instead of doing the series conversion. `df = df.loc[df.index.repeat(18)].reset_index(drop=True)` – Henry Ecker Aug 25 '21 at 18:22