简体   繁体   English

PySpark Juypter 笔记本显示器

[英]PySpark Juypter Notebook Displays

I am quite new to jupyter notebook, and I am struggling to reveal my spark table (image 1) in a neater way similar to a normal panda dataframe (image 2).我对 jupyter 笔记本很陌生,我正在努力以类似于普通熊猫 dataframe(图 2)的更简洁的方式展示我的 spark 表(图 1)。 I am trying not to use pandas.我试图不使用 pandas。

The display function doesnt work on spark dataframe:( Can someone help me? It will make it easier for me to analysis the spark table.显示 function 在 spark dataframe 上不起作用:(有人可以帮我吗?这将使我更容易分析 spark 表。 :

在此处输入图像描述

When you build your spark session, add the config.构建 spark session 时,添加配置。

.config("spark.sql.repl.eagerEval.enabled", True)

For example,例如,

import findspark
findspark.init()

from pyspark.sql import SparkSession

spark = SparkSession.builder \
          .master("local") \
          .config("spark.sql.repl.eagerEval.enabled", True) \
          .getOrCreate()

and just call the dataframe without .show as follows只需调用不带 .show 的.show如下

df

that will print the result in this way.将以这种方式打印结果。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM