简体   繁体   English

AttributeError:“ DataFrame”对象在VectorAssembler spark ML上没有属性“ get”

[英]AttributeError: 'DataFrame' object has no attribute 'get' on VectorAssembler spark ML

I'm trying to follow the example discussed here and I just copied the code into Zeppelin paragraph. 我试图遵循此处讨论的示例并将代码复制到Zeppelin段落中。

%pyspark
import pandas as pd
from pyspark.sql import SQLContext
from pyspark.ml.feature import VectorAssembler
from pyspark.mllib.linalg import Vectors

dataset = sqlContext.createDataFrame(
[(0, 18, 1.0, Vectors.dense([0.0, 10.0, 0.5]), 1.0)],
["id", "hour", "mobile", "userFeatures", "clicked"])
print(type(dataset))
assembler = VectorAssembler(
inputCols=["hour", "mobile", "userFeatures"],
outputCol="features")
output = assembler.transform(dataset)

However, I got this error: 但是,我收到此错误:

Traceback (most recent call last): 
  File "/tmp/zeppelin_pyspark.py", line 164, in <module> 
    intp.setStatementsFinished(output.get(), False) 
  File "/home/zeppelin/zeppelin-0.5.5-incubating-bin-all/interpreter/spark/pyspark/pyspark.zip/pyspark/sql/dataframe.py", line 749, in __getattr__ "'%s' object has no attribute '%s'" % (self.__class__.__name__, name)) 
AttributeError: 'DataFrame' object has no attribute 'get'

Any advice? 有什么建议吗?

you can try changing 你可以尝试改变

from pyspark.mllib.linalg import Vectors

with

from pyspark.ml.linalg import Vectors

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError: 'DataFrame' object 没有属性 - AttributeError: 'DataFrame' object has no attribute dask_ml Simple Imputer 失败,出现 AttributeError: 'DataFrame' object has no attribute '_data' - dask_ml Simple Imputer fails with AttributeError: 'DataFrame' object has no attribute '_data' AttributeError: 'DataFrame' object 没有属性 'get_value' - AttributeError: 'DataFrame' object has no attribute 'get_value' AttributeError: 'DataFrame' object 没有属性 'get_dtype_counts' - AttributeError: 'DataFrame' object has no attribute 'get_dtype_counts' Dataframe AttributeError:&#39;DataFrame&#39;对象没有属性&#39;icol&#39; - Dataframe AttributeError: 'DataFrame' object has no attribute 'icol' Spark AttributeError:“ SparkContext”对象没有属性“ map” - Spark AttributeError: 'SparkContext' object has no attribute 'map' Bokeh:AttributeError:&#39;DataFrame&#39;对象没有属性&#39;tolist&#39; - Bokeh: AttributeError: 'DataFrame' object has no attribute 'tolist' AttributeError: &#39;DataFrame&#39; 对象没有属性 &#39;Class&#39; - AttributeError: 'DataFrame' object has no attribute 'Class' AttributeError: &#39;DataFrame&#39; 对象没有属性 &#39;path&#39; - AttributeError: 'DataFrame' object has no attribute 'path' AttributeError: &#39;DataFrame&#39; 对象没有属性 &#39;save&#39; - AttributeError: 'DataFrame' object has no attribute 'save'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM