Imagine you have the following df:
lines
+----+-----------------+-----------------+-----------------+-----------------+-----------------+
| | line amount#1 | line amount#2 | line amount#3 | line amount#4 | line amount#5 |
|----+-----------------+-----------------+-----------------+-----------------+-----------------|
| 0 | 250 | 250 | 250 | 250 | 250 |
| 1 | 250 | 250 | 250 | 250 | 250 |
| 2 | 14 | 7.35 | 9.9 | 27.75 | nan |
+----+-----------------+-----------------+-----------------+-----------------+-----------------+
perc
+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+
| btw-percentage#1 | btw-percentage#2 | btw-percentage#3 | btw-percentage#4 | btw-percentage#5 | btw-percentage#6 |
|--------------------+--------------------+--------------------+--------------------+--------------------+--------------------|
| 10 | nan | nan | nan | nan | nan |
| nan | nan | nan | nan | nan | nan |
| nan | nan | nan | nan | nan | nan |
+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+
update = lines.to_numpy() / perc.to_numpy()
when dividing I get the following error:
ValueError: operands could not be broadcast together with shapes (3,5) (3,6)
Which is logical since the columns are not the same shape.
I want to trim the column shape of the perc column based on the length of the lines column. So that would become #5. Is this possible with numpy? desired output after division:
+----+-----------------+-----------------+-----------------+-----------------+-----------------+
| | line amount#1 | line amount#2 | line amount#3 | line amount#4 | line amount#5 |
|----+-----------------+-----------------+-----------------+-----------------+-----------------|
| 0 | 25 | 250 | 250 | 250 | 250 |
| 1 | 250 | 250 | 250 | 250 | 250 |
| 2 | 14 | 7.35 | 9.9 | 27.75 | nan |
+----+-----------------+-----------------+-----------------+-----------------+-----------------+
Please help!