首页 > 解决方案 > 在pyspark的pandas_udf中使用外部库

问题描述

可以在 pandas_udf 中使用像textdistance这样的外部库吗?我试过了,我得到了这个错误:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

我尝试过使用 Spark 2.3.1 版。

标签: pythonpandaspysparkuser-defined-functions

解决方案


您可以将其与您自己的代码打包textdistance在一起(使用 setup.py 并bdist_egg构建一个文件),并在运行 spark 时egg指定带有选项的最终包。--py-files

顺便说一句,错误消息似乎根本不相关textdistance


推荐阅读