我正在尝试在Mllib中迈出第一步。我的库依赖项是:
libraryDependencies += "org.apache.spark" % "spark-core_2.11" % "2.2.0"
libraryDependencies += "com.github.fommil.netlib" % "all" % "1.1.2"
Run Code Online (Sandbox Code Playgroud)
但我仍然得到:
Error:(4, 27) object ml is not a member of package org.apache.spark
import org.apache.spark.ml.regression.GeneralizedLinearRegression
Run Code Online (Sandbox Code Playgroud) 我有具有以下架构的 DataFrame:
|-- data: struct (nullable = true)
| |-- asin: string (nullable = true)
| |-- customerId: long (nullable = true)
| |-- eventTime: long (nullable = true)
| |-- marketplaceId: long (nullable = true)
| |-- rating: long (nullable = true)
| |-- region: string (nullable = true)
| |-- type: string (nullable = true)
|-- uploadedDate: long (nullable = true)
Run Code Online (Sandbox Code Playgroud)
我想分解结构,使 asin、customerId、eventTime 等所有元素都成为 DataFrame 中的列。我尝试了爆炸函数,但它适用于数组而不是结构类型。是否可以将数据框转换为以下数据框:
|-- asin: string (nullable = true)
|-- customerId: long (nullable = true) …
Run Code Online (Sandbox Code Playgroud) 我知道scala.collection包中有两个非常有用的对象,它们将帮助我们实现这个目标:
但是我在我的案例中应用它们有一些麻烦,因为我的数据结构比我在许多例子中看到的其他数据结构稍微复杂一些.
我在scala代码中,我希望我的scala函数返回Java集合.所以我想将Scala Seq [(Int,Seq [String])]转换为Java集合List [(int,List [String])].
我怎样才能做到这一点?
我正在使用以下函数来解析 url 但它会抛出错误,
val b = Seq(("http://spark.apache.org/path?query=1"),("https://people.apache.org/~pwendell/spark-nightly/spark-master-docs/latest/api/sql/#negative")).toDF("url_col")
.withColumn("host",parse_url($"url_col","HOST"))
.withColumn("query",parse_url($"url_col","QUERY"))
.show(false)
Run Code Online (Sandbox Code Playgroud)
错误:
<console>:285: error: not found: value parse_url
.withColumn("host",parse_url($"url_col","HOST"))
^
<console>:286: error: not found: value parse_url
.withColumn("query",parse_url($"url_col","QUERY"))
^
Run Code Online (Sandbox Code Playgroud)
请指导如何将 url 解析为不同的部分。