【问题标题】:Zeppelin: Problematic table display when mixing with stringsZeppelin:与字符串混合时有问题的表格显示
【发布时间】:2018-11-19 20:57:18
【问题描述】:

例如,如果我使用 z.show() 直接输出表格

%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())

输出很好,像这样

但是,如果我在输出表之间添加一个字符串

%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())

输出变成这个,(没有表格显示)

我想知道,如何将string和Zeppelin的table show混合在一起?

我认为问题可能是由于字符串导致 Zeppelin 的表格显示格式错误?

【问题讨论】:

    标签: pyspark apache-zeppelin


    【解决方案1】:

    嗯,这是齐柏林飞艇的问题。解决方法是添加 '%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())
    

    【讨论】:

      猜你喜欢
      • 2011-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-19
      • 1970-01-01
      • 1970-01-01
      • 2022-11-19
      • 1970-01-01
      相关资源
      最近更新 更多