从Spark DataFrame开始,为进一步的分析处理创建矢量矩阵.
feature_matrix_vectors = feature_matrix1.map(lambda x: Vectors.dense(x)).cache()
feature_matrix_vectors.first()
Run Code Online (Sandbox Code Playgroud)
输出是一个向量数组.其中一些向量中包含空值
>>> DenseVector([1.0, 31.0, 5.0, 1935.0, 24.0])
...
>>> DenseVector([1.0, 1231.0, 15.0, 2008.0, null])
Run Code Online (Sandbox Code Playgroud)
从这里我想迭代矢量矩阵并创建一个LabeledPoint数组,如果向量包含null,则为0(零),否则为1.
def f(row):
if row.contain(None):
LabeledPoint(1.0,row)
else:
LabeledPoint(0.0,row)
Run Code Online (Sandbox Code Playgroud)
我试图使用迭代遍历向量矩阵
feature_matrix_labeledPoint = (f(row) for row in feature_matrix_vectors) # create a generator of row sums
next(feature_matrix_labeledPoint) # Run the iteration protocol
Run Code Online (Sandbox Code Playgroud)
但这不起作用.
TypeError: 'PipelinedRDD' object is not iterable
Run Code Online (Sandbox Code Playgroud)
任何帮助都会很棒
我跟随讲师在本地Git存储库中设置了Zeppelin Notebook Storage:
https://zeppelin.incubator.apache.org/docs/0.6.0-incubating-SNAPSHOT/storage/storage.html#Git
但我仍然不清楚如何在Git中存储笔记本版本.有没有其他人试过这个,你的经历是什么?
我使用survivaljs.com 站点作为模板,使用webpack 构建基于地图的React 应用程序。对于地图,我使用的是传单,但我找不到添加传单.css 的方法。如果没有这个,地图图块将以错误的顺序显示。
我已经尝试使用这个将 Leaflet.css 添加到 App.jsx 文件中
require('leaflet/dist/leaflet.css');
Run Code Online (Sandbox Code Playgroud)
但得到以下错误
ERROR in ./~/leaflet/dist/leaflet.css
Module parse failed: myApp/node_modules/leaflet/dist/leaflet.css Unexpected token (3:0)
You may need an appropriate loader to handle this file type.
Run Code Online (Sandbox Code Playgroud)
如果我可以访问 index.html,我可以将它添加到那里,但是我使用 webpack,我不清楚该怎么做?
我正在将公司记录加载到spark中
case class Company(id:Integer, name:String, kind: String, location : String, stage:String)
Run Code Online (Sandbox Code Playgroud)
这是一个大型数据文件,所以我想弄清楚哪个公司记录正确加载
safe: [S, T](f: S => T)S => Either[T,(S, Exception)]
Run Code Online (Sandbox Code Playgroud)
用数据加载
val companiesText = sc.textFile("../companies.txt");
val safeParse = safe(parse)
val companyRecords = companiesText.map(line => line.split(";")).map(line => safeParse(line))
Run Code Online (Sandbox Code Playgroud)
访问正确加载的公司记录
val goodCompaniesRecords = companyRecords.collect({
case t if t.isLeft => t.left.get
})
Run Code Online (Sandbox Code Playgroud)
这给出了一个Array [Product with Serializable],我无法访问这些元素
goodCompaniesRecords.map(x => new Company(x._1, x._2, x._3, x._4, x._5))
Run Code Online (Sandbox Code Playgroud)
给
error: value _1 is not a member of Product with Serializable
goodCompaniesRecords.map(x => new Company(x._1, x._2, x._3, …Run Code Online (Sandbox Code Playgroud)