pyspark - 如何在 PySpark 中保存列计算语句?
问题描述
我有一段 pyspark 代码,它是以编程方式生成的,而且生成起来很昂贵。我想生成状态并保存它。但是pickle不能用来保存语句。有没有办法做到这一点?
from pyspark.sql import functions as F
# the real statement is more complex and expensive to generate
statement = F.when(F.col("col") < 0.5).when(F.col("col2")<0.6)
import pickle
pickle.dump(statement, "statement.pickle")
#TypeError: file must have a 'write' attribute
解决方案
推荐阅读
- reactjs - 给出类型“测试”的打字稿不能分配给类型“未定义”
- angular - Angular 12. ApplicationRef 的循环依赖
- python - 如何使用一个模型中的字段信息来计算另一个模型中的另一个字段?
- python - 是否有 Python 代码可以直接写入 SQLite 命令行?
- python - 如何在 Django 中推荐项目?
- android - 为什么我的安全客户端连接可以在 android 上运行,但不能在 ios 上运行?
- javascript - Javascript视差对具有限制范围的图像的影响
- firebase - 我对 firebase 身份验证有疑问
- python - Django 中的 cached_property 与 Python 的 functools 有什么区别?
- c++ - 如何从 FLTK Fl__Image__Surface 获取具有透明背景的图像?