I'm stuck on a problem with dataframes due to the lack of understanding in looping/iterating/matrices/etc.
so I have a dataframe or an array (whatever works):
initial = [[1,2,3,3], [4,5,6,6],[7,8,9,9]]
I need to divide all the values in the array/df excluding the last column by the values of the last column row by row, so that I obtain the result:
result = [[0.33, 0.66, 1], [0.66, 0.83, 1],[0.77, 0.88,1]]
So e.g. I would go with the first list like so: 1/3, 2/3, 3/3, then take the next list and divide 4/6, 5/6, 6/6, and so on...
I would want to either store the result in a separate df/array or overwrite the original df/array, whatever works best. Note (if it matters): the last column does not contain 0 (nulls) or NaNs and the values are equal or greater than the values in the preceding columns (based on each row).
I'd also like to know if I can determine the rows to go by based on a column that stands before column 0 (originally I dropped this column to just have the numbers and add it later, but it would be an absolute plus, if the rows would be calculated related to this column which contains unique strings (they're set index to my original dataframe)