I have the following data frame:
For each entry of this data frame, I am looking to get the sum of log(df['s_i']/df['s_18'])*log(i/18) for i in h = [18, 56, 98, 123, 148].
I tried the following:
a = [] h = [18, 56, 98, 123, 148] for i in df.index: for zi in h: a.append(log(df.loc[i,'s_'+str(zi)]/df.loc[i,'s_18'])*log(zi/18)) b = sum(a)
However, it did not work. Any idea how to solve this problem? Any help would be greatly appreciated!
https://stackoverflow.com/questions/66827853/using-a-loop-to-get-a-sum-of-computed-values-using-column-math-for-each-datafr March 27, 2021 at 11:53AM
没有评论:
发表评论