Reputation: 36
columnData.tolist() outputs the following
[19.51 15.45 16.67 0. 12.06 5.97 15.56 0. 12.8 17.58]
I want it so, that each position in the list will be converted a sum of all other values.
Below is the code I am trying.
templ = [ sum( columnData.tolist().pop(i) )
for i,l in enumerate(columnData.tolist()) ]
And the output is: ''' TypeError: 'float' object is not iterable '''
Upvotes: 1
Views: 67
Reputation: 8111
Simple implementation using list comprehension.
lst = [] #your_list
s = sum(lst)
new_lst = [s-i for i in lst]
Upvotes: 5