[ 
https://issues.apache.org/jira/browse/SPARK-22980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16317100#comment-16317100
 ] 

Hyukjin Kwon commented on SPARK-22980:
--------------------------------------

Could we just fix it by adding a simple note that the length of serises or 
dataframe within pandas_udf is not of whole serises or dataframe but of batch 
internally used, for now?

I think that's going to explain the difference of the results of len between 
udf and pandas_udf more clearly because udf returns the length of the value 
whereas pandas_udf returns the length of the batch.

> Using pandas_udf when inputs are not Pandas's Series or DataFrame
> -----------------------------------------------------------------
>
>                 Key: SPARK-22980
>                 URL: https://issues.apache.org/jira/browse/SPARK-22980
>             Project: Spark
>          Issue Type: Sub-task
>          Components: PySpark
>    Affects Versions: 2.3.0
>            Reporter: Xiao Li
>
> {noformat}
> from pyspark.sql.functions import pandas_udf
> from pyspark.sql.functions import col, lit
> from pyspark.sql.types import LongType
> df = spark.range(3)
> f = pandas_udf(lambda x, y: len(x) + y, LongType())
> df.select(f(lit('text'), col('id'))).show()
> {noformat}
> {noformat}
> from pyspark.sql.functions import udf
> from pyspark.sql.functions import col, lit
> from pyspark.sql.types import LongType
> df = spark.range(3)
> f = udf(lambda x, y: len(x) + y, LongType())
> df.select(f(lit('text'), col('id'))).show()
> {noformat}
> The results of pandas_udf are different from udf. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to