UDF:IndentationError:unindent与任何外部缩进级别都不匹配

时间:2017-07-28 08:18:19

标签: python apache-spark

当我执行此代码时,我收到错误IndentationError: unindent does not match any outer indentation level

def calculate(num1, num2):
    if (num1/num2 > 1): 
        num1 = num2
    result = (num1 - num2) / math.sqrt(1-(num1/num2))
    return result   
df = udf(calculate, FloatType())

我做错了什么?

1 个答案:

答案 0 :(得分:0)

您发布的代码没有缩进错误。查看错误消息中报告的行号。你会看到这样的东西:

xxxx
    xxxxx
    xxxxx
   xxxxx
   ^ this is the unindent that is causing the problem