python - 在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 版。
解决方案
您可以将其与您自己的代码打包textdistance
在一起(使用 setup.py 并bdist_egg
构建一个文件),并在运行 spark 时egg
指定带有选项的最终包。--py-files
顺便说一句,错误消息似乎根本不相关textdistance
。
推荐阅读
- flutter - 如何将 ListView.builder 放入抽屉中?
- c# - System.DirectoryServices.DirectoryServicesCOMException:发生约束冲突
- android - 是否可以在没有关联 URL 的情况下发布即时应用程序?
- elasticsearch - 使用 curl 命令从 elasticsearch 中删除时出错
- python - 熊猫没有正确计算行数
- mobile-safari - Next.js:Mobile Safari 在加载 hot-update.json 时出现“加载资源失败:服务器响应状态为 404(未找到)”
- sql - 如何在 postgresql 中选择整数数组
- reactjs - 在 next.js 网站中加载页面后组件样式不会重新呈现
- browser - 网站可以通过 Puppeteer 检测到何时使用 Chromium?
- c - 编译C:collect2.exe:错误:ld返回1退出状态