Zeppelin: Scala Dataframe to python

僤鯓⒐⒋嵵緔 提交于 2019-11-27 19:53:18

You can register DataFrame as a temporary table in Scala:

// registerTempTable in Spark 1.x
df.createTempView("df")

and read it in Python with SQLContext.table:

df = sqlContext.table("df")

If you really want to use put / get you'll have build Python DataFrame from scratch:

z.put("df", df: org.apache.spark.sql.DataFrame)
from pyspark.sql import DataFrame

df = DataFrame(z.get("df"), sqlContext)

To plot with matplotlib you'll have convert DataFrame to a local Python object with either collect or toPandas:

pdf = df.toPandas()

Please note that it will fetch data to the driver.

See also moving Spark DataFrame from Python to Scala whithn Zeppelin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!