I have a dataframe with this format, generated by pivoting an excel file:
Gene Ref y z
Sample
1 29.2877 29.0625 20.9868
2 29.9897 32.8044 25.8783
3 31.6335 34.7172 24.6268
I want to perform a calculation with columns ref and y, then with ref and z, to generate 2 new columns. I know how to do these individually but I want something where I can specify how many columns need to be evaluated (y, z... etc), based on a number_of_columns = len(list) object generated earlier. Ideally, I'd also like the new columns to have names taken from another set that is also generated earlier. I always have the ref column as the first column, so I was trying something like this:
while number_of_columns != 0:
for column in df[(number_of_columns + 2)].iteritems():
df[set_of_names_of_new_columns] = df.(names_of_columns_to_use) + df[ref_column]
number_of_columns -= 1
Obviously this doesn't work but I have put it in to show what I was thinking. This also isn't the calculation but just simplified here.
Any help very much appreciated!