I have a data frame that looks like below.
unique_key #rows_needed avalue
a 2 1000
b 1 1000
c 5 2500
d 18 10000
I am trying to create a dateframe that looks like this based on the number of rows_needed and calculates the avg(avalue) depending on the rows_needed column.
unique_key #rows_needed avg(avalue)
a 2 500
a 2 500
b 1 1000
c 5 500
c 5 500
c 5 500
c 5 500
c 5 500
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
d 18 555.556
I took a look at the melt function in pandas, but I do not believe that will work. Any help is appreciated.