我在 运行 pandas 中的函数时出现错误 dataframe.I 函数第一行的语法无效
I am getting an error while i am running a function in pandas dataframe.I am getting invalid syntax for the first line of the function
def revised_price(引擎位置,价格):
如果引擎位置==前面:
updated_price==价格
别的:
updated_price== 2*价格
return new_profit
df['updated_price'] = df.apply(lambda x: revised_price(x['engine-location'], x['price']),axis= 1)
请找出我遇到的错误
文件“”,第 1 行
def revised_price(引擎位置,'价格):
^
语法错误:语法无效
您没有遵循此处的命名约定
你不能在像 engine-location 这样的函数内部命名,而是将其重命名为 engine_location,而不是
updated_price == price
尝试
updated_price = price
而不是
updated_price == 2*price
使用
updated_price = 2*price
def revised_price(引擎位置,价格): 如果引擎位置==前面: updated_price==价格 别的: updated_price== 2*价格
return new_profit
df['updated_price'] = df.apply(lambda x: revised_price(x['engine-location'], x['price']),axis= 1)
请找出我遇到的错误 文件“”,第 1 行 def revised_price(引擎位置,'价格): ^ 语法错误:语法无效
您没有遵循此处的命名约定
你不能在像 engine-location 这样的函数内部命名,而是将其重命名为 engine_location,而不是
updated_price == price
尝试
updated_price = price
而不是
updated_price == 2*price
使用
updated_price = 2*price