title: How do I pass multiple arguments to a Pandas UDF in PySpark?
body: <p>I'm working with the following snippet:</p>
  <pre><code>from cape_privacy.pandas.transformations import Tokenizer
  
  max_token_len = 5
  
  
  @pandas_udf(&quot;string&quot;)
  
  def Tokenize(column: pd.Series)-&gt; pd.Series:
    tokenizer = Tokenizer(max_token_len)
    return tokenizer(column)
  
  
  spark_df = spark_df.withColumn(&quot;name&quot;, Tokenize(&quot;name&quot;))
  </code></pre>
  <p>Since Pandas UDF only uses Pandas series I'm unable to pass the <code>max_token_len</code> argument in the function call <code>Tokenize(&quot;name&quot;)</code>.</p>
  <p>Therefore I have to define the <code>max_token_len</code> argument outside the scope of the function.</p>
  <p>The workarounds provided in <a href="https://stackoverflow.com/questions/53845951/pyspark-multiple-parameters-for-pandas-udf-grouped-agg">this question</a> weren't really helpful.
  Are there any other possible workarounds or alternatives to this issue?</p>
  <p>Please Advise</p>