Zeppelin:与字符串混合时有问题 table 显示
Zeppelin: Problematic table display when mixing with strings
比如我用z.show()直接输出table
%pyspark
df = spark.createDataFrame([
(0, 0, "2018-06-03", "2018-06-03"),
(1, 1, "2018-06-04", "2018-06-04"),
(2, 10, "2018-06-03", None),
(4, 1, "2018-06-05", "2018-06-01")])\
.toDF("orderid", "customerid", "product_name", "product_name2")
print("test print string 1")
z.show(df)
z.show(df.describe())
输出很好,像这样
但是,如果我在输出 tables
之间添加一个字符串
%pyspark
df = spark.createDataFrame([
(0, 0, "2018-06-03", "2018-06-03"),
(1, 1, "2018-06-04", "2018-06-04"),
(2, 10, "2018-06-03", None),
(4, 1, "2018-06-05", "2018-06-01")])\
.toDF("orderid", "customerid", "product_name", "product_name2")
print("test print string 1")
z.show(df)
print("test print string 2") # If I add this
z.show(df.describe())
输出变成这样,(没有显示 table)
我想知道,如何将字符串和 Zeppelin 的 table 显示一起显示?
我认为问题可能是由于字符串导致 Zeppelin 的 table 显示格式错误?
嗯,这是飞艇的问题。解决方法是添加“%text”以明确指定输出类型,如下所示
df = spark.createDataFrame([
(0, 0, "2018-06-03", "2018-06-03"),
(1, 1, "2018-06-04", "2018-06-04"),
(2, 10, "2018-06-03", None),
(4, 1, "2018-06-05", "2018-06-01")])\
.toDF("orderid", "customerid", "product_name", "product_name2")
print("test print string 1")
z.show(df)
print("%text test print string 2") # If I add this
z.show(df.describe())
比如我用z.show()直接输出table
%pyspark
df = spark.createDataFrame([
(0, 0, "2018-06-03", "2018-06-03"),
(1, 1, "2018-06-04", "2018-06-04"),
(2, 10, "2018-06-03", None),
(4, 1, "2018-06-05", "2018-06-01")])\
.toDF("orderid", "customerid", "product_name", "product_name2")
print("test print string 1")
z.show(df)
z.show(df.describe())
输出很好,像这样
但是,如果我在输出 tables
之间添加一个字符串%pyspark
df = spark.createDataFrame([
(0, 0, "2018-06-03", "2018-06-03"),
(1, 1, "2018-06-04", "2018-06-04"),
(2, 10, "2018-06-03", None),
(4, 1, "2018-06-05", "2018-06-01")])\
.toDF("orderid", "customerid", "product_name", "product_name2")
print("test print string 1")
z.show(df)
print("test print string 2") # If I add this
z.show(df.describe())
输出变成这样,(没有显示 table)
我想知道,如何将字符串和 Zeppelin 的 table 显示一起显示?
我认为问题可能是由于字符串导致 Zeppelin 的 table 显示格式错误?
嗯,这是飞艇的问题。解决方法是添加“%text”以明确指定输出类型,如下所示
df = spark.createDataFrame([
(0, 0, "2018-06-03", "2018-06-03"),
(1, 1, "2018-06-04", "2018-06-04"),
(2, 10, "2018-06-03", None),
(4, 1, "2018-06-05", "2018-06-01")])\
.toDF("orderid", "customerid", "product_name", "product_name2")
print("test print string 1")
z.show(df)
print("%text test print string 2") # If I add this
z.show(df.describe())