【发布时间】:2019-07-26 07:19:37
【问题描述】:
我正在阅读一个 csv 文件,其中包含 |最后的分隔符,而加载方法使数据框中的最后一列在 Spark 1.6 中没有名称且没有值
df.withColumnRenamed(df.columns(83),"Invalid_Status").drop(df.col("Invalid_Status"))
val df = sqlContext.read.format("com.databricks.spark.csv").option("delimiter","|").option("header","true").load("filepath")
val df2 = df.withColumnRenamed(df.columns(83),"Invalid_Status").
I expected result
root
|-- FddCell: string (nullable = true)
|-- Trn_time: string (nullable = true)
|-- CELLNAME.FddCell: string (nullable = true)
|-- Invalid_Status: string (nullable = true)
but actual output is
root
|-- FddCell: string (nullable = true)
|-- Trn_time: string (nullable = true)
|-- CELLNAME.FddCell: string (nullable = true)
|-- : string (nullable = true)
with no value in column so I have to drop this column and again make new column.
【问题讨论】:
-
所以您希望它为 Null?您希望该列的值是多少?
标签: scala dataframe apache-spark apache-spark-sql