如何在 Zeppelin 中的 %pyspark 解释器和 %python 解释器之间传递数据集? [英] How can I pass datasets between %pyspark interpreter and %python interpreters in Zeppelin?

查看:82
本文介绍了如何在 Zeppelin 中的 %pyspark 解释器和 %python 解释器之间传递数据集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写代码,其中使用内部库和 %pyspark 解释器获取数据集.但是我无法将数据集传递给 %python 解释器.我尝试使用字符串变量并且它工作正常,但是对于数据集,我使用以下代码将数据集放在 zeppelin 上下文中 - <代码>z.put("input_data",input_data)

I'm writing a code where I'm fetching a dataset using an internal library and %pyspark interpreter. However I am unable to pass the dataset to %python interpreter. I tried using string variables and it is working fine, but with dataset I'm using the following code to put dataset in a zeppelin context- z.put("input_data",input_data)

它抛出以下错误:

AttributeError: 'DataFrame' 对象没有属性 '_get_object_id'.

你能告诉我我该怎么做吗?提前致谢.

Can you please tell me how can I do this? Thanks in advance.

推荐答案

您可以通过将结果打印到 %table 将其放入 ResourcePool.

You can put the result in ResourcePool via print it to %table.

%python
print('%table a\tb\n408+\t+408\n0001\t++99\n40817810300001453030\t0000040817810300001453030')

那就这样吧.

%spark.pyspark
ic = z.getInterpreterContext()
pool = ic.getResourcePool()
paragraphId = "20180828-093109_1491500809"
t = pool.get(ic.getNoteId(), paragraphId, "zeppelin.paragraph.result.table").get().toString()

print(t)

这种方式允许传输多达 50-100 兆字节的原始数据.

This way allows to transfer up to 50-100 megabytes of raw data.

无论如何,我建议跟随@zjffdu 只使用这些解释器中的一个.

Anyway I recommend to follow @zjffdu to use only one of these interpreters.

这篇关于如何在 Zeppelin 中的 %pyspark 解释器和 %python 解释器之间传递数据集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆