a for loop to generate multiple data frames in python -
i new python , trying clean code using function generates many data frames desire. want df1, df2, df3, etc. out reading in different lists (one, two, three, etc.). variable "input" same. here code:
thx!
convert list data frame
import numpy np import pandas pd df1 = pd.dataframe(one, columns=[(input.cell(0, 0)).value + 'a', (input.cell(0, 0)).value + 'b', (input.cell(0, 2)).value + 'a', (input.cell(0, 2)).value + 'b', (input.cell(0, 3)).value + 'a', (input.cell(0, 3)).value + 'b', (input.cell(0, 4)).value + 'a', (input.cell(0, 4)).value + 'b', (input.cell(0, 5)).value + 'a', (input.cell(0, 5)).value + 'b', (input.cell(0, 6)).value + 'a', (input.cell(0, 6)).value + 'b', (input.cell(0, 7)).value + 'a', (input.cell(0, 7)).value + 'b', (input.cell(0, 8)).value + 'a', (input.cell(0, 8)).value + 'b', 'pos1', 'mut1']) # replacement of '' nan df1 = df1.replace('', np.nan, regex=true) # calculate differences between individual clones in range(2, 9): df1[(input.cell(0, i)).value + '_dab'] = diff(df1[(input.cell(0, i)) .value + 'a'], df1[(input.cell(0, i)) .value + 'b'])
for in range(number_of_your_desire): df1[(input.cell(0, i)).value + '_dab'] = diff(df1[(input.cell(0, 2)).value + 'a'], df1[(input.cell(0, i)).value + 'b'])
Comments
Post a Comment