vegas bar nosuchmethoderror-带Dataframe

cnh2zyt3  于 2021-05-27  发布在  Spark
关注(0)|答案(0)|浏览(232)

我正在用维加斯图书馆用scala和jupyter笔记本上的spark进行简单的可视化实验。
我已经成功地安装了杏仁内核并导入了所有必要的方法。我可以启动sparksession并使用scala代码而不会出现问题。
然而,当涉及到用spark dataframe实际绘制条形图时,似乎无法识别withdataframe方法。请告知。

import $ivy.`org.vegas-viz:vegas_2.11:0.3.11`
import $ivy.`org.vegas-viz:vegas-spark_2.11:0.3.11`
import $ivy.`org.apache.spark::spark-sql:2.4.0`
import $ivy.`sh.almond::almond-spark:0.10.6`

import org.apache.spark.sql._
import org.apache.spark.sql.types

val spark = {
  NotebookSparkSession.builder()
    .master("local[*]")
    .getOrCreate()
}

val intDF = spark.read.option("header","true").csv("customer_interactions.csv")

import vegas._
import vegas.render.WindowRenderer._
import vegas.sparkExt._

val plotDF = intDF.groupBy("offer").count

plotDF.schema
res11: types.StructType = StructType(
  StructField("offer", StringType, true, {}),
  StructField("count", LongType, false, {})
)

Vegas("Offer Count")
    .withDataFrame(plotDF)
    .encodeX("offer", Ordinal)
    .encodeY("count", Quantitative)
    .mark(Bar)
    .show

**ERROR Execute exception in user code (scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps;)

java.lang.NoSuchMethodError:**scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps;
  vegas.sparkExt.package$VegasSpark.withDataFrame(package.scala:16)
  ammonite.$sess.cmd35$Helper.<init>(cmd35.sc:2)
  ammonite.$sess.cmd35$.<init>(cmd35.sc:7)
  ammonite.$sess.cmd35$.<clinit>(cmd35.sc)
  ammonite.$sess.cmd35.$main(cmd35.sc)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.lang.reflect.Method.invoke(Method.java:498)
  ammonite.runtime.Evaluator$$anon$1.$anonfun$evalMain$1(Evaluator.scala:108)
  ammonite.util.Util$.withContextClassloader(Util.scala:24)
  ammonite.runtime.Evaluator$$anon$1.evalMain(Evaluator.scala:90)
  ammonite.runtime.Evaluator$$anon$1.$anonfun$processLine$2(Evaluator.scala:127)
  ammonite.util.Catching.map(Res.scala:117)
  ammonite.runtime.Evaluator$$anon$1.$anonfun$processLine$1(Evaluator.scala:121)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  ammonite.runtime.Evaluator$$anon$1.processLine(Evaluator.scala:120)
  ammonite.interp.Interpreter.$anonfun$evaluateLine$4(Interpreter.scala:296)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  ammonite.interp.Interpreter.$anonfun$evaluateLine$2(Interpreter.scala:282)
  ammonite.util.Catching.flatMap(Res.scala:115)
  ammonite.interp.Interpreter.evaluateLine(Interpreter.scala:281)
  ammonite.interp.Interpreter.$anonfun$processLine$6(Interpreter.scala:268)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  ammonite.interp.Interpreter.$anonfun$processLine$4(Interpreter.scala:252)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  ammonite.interp.Interpreter.$anonfun$processLine$2(Interpreter.scala:245)
  ammonite.util.Catching.flatMap(Res.scala:115)
  ammonite.interp.Interpreter.processLine(Interpreter.scala:244)
  almond.Execute.$anonfun$ammResult$9(Execute.scala:226)
  almond.internals.CaptureImpl.$anonfun$apply$2(CaptureImpl.scala:53)
  scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
  scala.Console$.withErr(Console.scala:196)
  almond.internals.CaptureImpl.$anonfun$apply$1(CaptureImpl.scala:45)
  scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
  scala.Console$.withOut(Console.scala:167)
  almond.internals.CaptureImpl.apply(CaptureImpl.scala:45)
  almond.Execute.capturingOutput(Execute.scala:164)
  almond.Execute.$anonfun$ammResult$8(Execute.scala:222)
  almond.Execute.$anonfun$withClientStdin$1(Execute.scala:144)
  scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
  scala.Console$.withIn(Console.scala:230)
  almond.Execute.withClientStdin(Execute.scala:140)
  almond.Execute.$anonfun$ammResult$7(Execute.scala:222)
  almond.Execute.withInputManager(Execute.scala:132)
  almond.Execute.$anonfun$ammResult$6(Execute.scala:221)
  ammonite.repl.Signaller.apply(Signaller.scala:28)
  almond.Execute.interruptible(Execute.scala:181)
  almond.Execute.$anonfun$ammResult$5(Execute.scala:220)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  almond.Execute.$anonfun$ammResult$1(Execute.scala:211)
  almond.Execute.withOutputHandler(Execute.scala:155)
  almond.Execute.ammResult(Execute.scala:211)
  almond.Execute.apply(Execute.scala:295)
  almond.ScalaInterpreter.execute(ScalaInterpreter.scala:117)
  almond.interpreter.InterpreterToIOInterpreter.$anonfun$execute$2(InterpreterToIOInterpreter.scala:69)
  cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:87)
  cats.effect.internals.IORunLoop$RestartCallback.signal(IORunLoop.scala:355)
  cats.effect.internals.IORunLoop$RestartCallback.apply(IORunLoop.scala:376)
  cats.effect.internals.IORunLoop$RestartCallback.apply(IORunLoop.scala:316)
  cats.effect.internals.IOShift$Tick.run(IOShift.scala:36)
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  java.lang.Thread.run(Thread.java:748)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题