Say I’ve a Python list as below:
list = [ ['text',2,3,4], ['text2',4,5,6] ]
y= map(sum,zip(*list))
print y
Gives int /str error.
How would I pop all ‘text’ in all rows and sum the remaining columns.
Ans: Im looking for [6, 8, 10]
I noticed that field look like int but are str. 4 vs ‘4’.
If you don’t know a priori which columns contain text, then you could use a try..except block to handle the text: