title: PickleException: expected zero arguments for construction of ClassDict (for numpy.dtype)
body: <p>I don't understand how this could be fixed, I went through on some of the questions here already, but didn't find a perfectly fitting answer.</p>
  <p>I have a dataframe which has the following important columns: building_id, area, height.</p>
  <p>The UDF I tried to write calculates a difference between the square root of the area and the height. It returns a value, which should be added to the dataframe.</p>
  <pre><code>def calculate_difference(area, height):
    # calculate the square root of the area
    import numpy as np
    nr = np.sqrt(area)
    
    # calculate the difference between the square root of the area and the height
    dif = nr - height
    
    return dif
  </code></pre>
  <p>And then I register this UDF:</p>
  <pre><code>calculate_differenceUDF = udf(calculate_difference)
  </code></pre>
  <p>The function works when I pass two numbers, it returns the value I expect. I want to add a new column to my dataframe, where we have a calculated value, based on the function.</p>
  <pre><code>display(df.withColumn(&quot;diff&quot;, calculate_differenceUDF(col(&quot;area&quot;), col(&quot;height&quot;))))
  </code></pre>
  <p>Then I receive this error:</p>
  <blockquote>
  <p>PickleException: expected zero arguments for construction of ClassDict
  (for numpy.dtype)</p>
  </blockquote>
  <p>I understand that I don't return maybe a correct type, but I don't see how to fix it! :)</p>