Essentially your list comprehension statement is a set of 3 nested loops. In code:
l = []
for x in df2['apples']:
for y in df2['oranges']:
for z in df2['bananas']:
l.extend([x * y - z])
The length of your resultant list will be 3 times the length of your DataFrame. Hence the error. To fix, you need the equivalent of:
for x, y, z in zip(df2['apples'], df2['oranges'], df2['bananas']):
l.extend([x * y - z])
In terms of list comprehension:
[x * y - z for x, y, z in zip(df2['apples'], df2['oranges'], df2['bananas'])]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…