Loops 循环、语法错误和ValueError
我有一个非常简单的df,[12行x 6列]。我正试图从中获取一些数据,并做一些简单的算术运算,以便能够向df添加一个新列。但是当我尝试在df中运行循环时,会出现语法错误Loops 循环、语法错误和ValueError,loops,syntax-error,valueerror,Loops,Syntax Error,Valueerror,我有一个非常简单的df,[12行x 6列]。我正试图从中获取一些数据,并做一些简单的算术运算,以便能够向df添加一个新列。但是当我尝试在df中运行循环时,会出现语法错误 savings = [] for i,j in df_compar: i = min(df_compar.iloc[[0:5],[0:11]]) j = max(df_compar.iloc[[0:5],[0:11]]) df = round((1-(i/j))*100,2)
savings = []
for i,j in df_compar:
i = min(df_compar.iloc[[0:5],[0:11]])
j = max(df_compar.iloc[[0:5],[0:11]])
df = round((1-(i/j))*100,2)
savings.append(df)
savings
文件“”,第3行
i=最小值(df_比较iloc[[0:5],[0:11])
^
SyntaxError:无效语法
如果我没有指定任何行或列(我希望循环在所有df中运行),它会给出另一个错误
ValueError回溯(最近一次调用上次)
在()
1节省=[]
---->2对于df_比较中的i,j:
3 i=最小值(df_比较iloc[[]))
4 j=最大值(df_比较iloc[[]))
5 df=圆形((1-(i/j))*100,2)
ValueError:要解压缩的值太多(应为2个)
我将感谢任何帮助