title: Pyspark: multiple parameters for pandas_udf, grouped_agg
body: <p>I am trying to apply a pandas_udf, with two parameters. But I've got this error.
  First I try with one parameter and it's ok:</p>
  
  <pre><code>from pyspark.sql.functions import pandas_udf, PandasUDFType
  from pyspark.sql import SparkSession
  from pyspark.sql.types import *
  
  spark = SparkSession \
          .builder \
          .config('spark.cores.max', 100) \
          .getOrCreate()
  
  df = spark.createDataFrame(
      [(1, 1.0), (1, 2.0), (2, 3.0), (2, 5.0), (2, 10.0)],
      ("id", "v"))
  </code></pre>
  
  <p>This is how the data looked like </p>
  
  <pre><code>+---+----+
  | id|   v|
  +---+----+
  |  1| 1.0|
  |  1| 2.0|
  |  2| 3.0|
  |  2| 5.0|
  |  2|10.0|
  +---+----+
  </code></pre>
  
  <p>My pandas_udf function is </p>
  
  <pre><code>@pandas_udf("double", PandasUDFType.GROUPED_AGG)
  def count_udf(v):
      cond = v&lt;=3
      res = v[cond].count()
      return res
  df.groupby("id").agg(count_udf(df['v'])).show()
  </code></pre>
  
  <p>and the result is</p>
  
  <pre><code>+---+------------+
  | id|count_udf(v)|
  +---+------------+
  |  1|         2.0|
  |  2|         1.0|
  +---+------------+
  </code></pre>
  
  <p>But when I try to put two parameters for the pandas_udf function as follow, I have an error.</p>
  
  <pre><code>@pandas_udf("double", PandasUDFType.GROUPED_AGG)
  def count_udf2(v, value):
      cond = v&lt;=value
      res = v[cond].count()
      return res
  
  df.groupby("id").agg(count_udf(df['v'],4)).show()
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 3267, in run_code
      exec(code_obj, self.user_global_ns, self.user_ns)
    File "&lt;ipython-input-18-468499490a1f&gt;", line 1, in &lt;module&gt;
      res = df.groupby("id").agg(count_udf(df['v'],4))
    File "/home/idswb/.local/lib/python3.6/site-packages/pyspark/sql/udf.py", line 189, in wrapper
      return self(*args)
    File "/home/idswb/.local/lib/python3.6/site-packages/pyspark/sql/udf.py", line 169, in __call__
      return Column(judf.apply(_to_seq(sc, cols, _to_java_column)))
    File "/home/idswb/.local/lib/python3.6/site-packages/pyspark/sql/column.py", line 65, in _to_seq
      cols = [converter(c) for c in cols]
    File "/home/idswb/.local/lib/python3.6/site-packages/pyspark/sql/column.py", line 65, in &lt;listcomp&gt;
      cols = [converter(c) for c in cols]
    File "/home/idswb/.local/lib/python3.6/site-packages/pyspark/sql/column.py", line 53, in _to_java_column
      "function.".format(col, type(col)))
  TypeError: Invalid argument, not a string or column: 4 of type &lt;class 'int'&gt;. For column literals, use 'lit', 'array', 'struct' or 'create_map' function.
  </code></pre>