如何解决 cannot assign to function call in this Python code
How to solve cannot assign to function call in this Python code
#Start cleaning loop through all the pings
for P in Pings:
#All beams for current ping
print("Cleansing completed", round(P/len(Pings)*100,1),"%")
Slice_one = df[(df.P==P)&(df.Bm>0)&(df.Bm<257)].copy()
model = LinearRegression().fit(Slice_one.Bm.values.reshape((-1,1)), Slice_one.Z.values)
Slice_one["Z_1"] = model.predict(Slice_one.Bm.values.reshape((-1,1)))
Slice_one("dZ") = abs(Slice_one.Z_1 - Slice_one.Z)
Slice_one_Cor = Slice_one[(Slice_one.dZ < 0.4)]
Slice_one_Cor.drop(["Z_1", "dZ"], axis = 1, inplace = True)
df_Clean = pd.concat([df.Clean, Slice_one_cor], ignore_index = True)
文件“”,第 13 行
Slice_one("dZ") = abs(Slice_one.Z_1 - Slice_one.Z)
^
语法错误:无法分配给函数调用
你必须使用方括号 [ ], Slice_one["dZ"] = abs(Slice_one.Z_1 - Slice_one.Z)
#Start cleaning loop through all the pings
for P in Pings:
#All beams for current ping
print("Cleansing completed", round(P/len(Pings)*100,1),"%")
Slice_one = df[(df.P==P)&(df.Bm>0)&(df.Bm<257)].copy()
model = LinearRegression().fit(Slice_one.Bm.values.reshape((-1,1)), Slice_one.Z.values)
Slice_one["Z_1"] = model.predict(Slice_one.Bm.values.reshape((-1,1)))
Slice_one("dZ") = abs(Slice_one.Z_1 - Slice_one.Z)
Slice_one_Cor = Slice_one[(Slice_one.dZ < 0.4)]
Slice_one_Cor.drop(["Z_1", "dZ"], axis = 1, inplace = True)
df_Clean = pd.concat([df.Clean, Slice_one_cor], ignore_index = True)
文件“”,第 13 行 Slice_one("dZ") = abs(Slice_one.Z_1 - Slice_one.Z) ^ 语法错误:无法分配给函数调用
你必须使用方括号 [ ], Slice_one["dZ"] = abs(Slice_one.Z_1 - Slice_one.Z)