環境 Python 3.7 with Spark, watson studio
python
1def getListsForRunChart(df,spark): 2 temp_ts=spark.sql("SELECT temperature,ts from washing where temperature is not null order by ts asc") 3 temp_ts_rdd=temp_ts.rdd.sample(False,0.1).map(lambda row:(row.ts,row.temperature)) 4 ts=temp_ts_rdd.map(lambda ts,voltage:ts).collect() 5 temperature=temp_ts_rdd.map(lambda ts,voltage:voltage).collect() 6 x=ts,temperature 7 return x
このコードを定義して
python
1lists = getListsForRunChart(df,spark)
このコードを実行しようとしたのですが
Py4JJavaError Traceback (most recent call last)
<ipython-input-16-c153c3457934> in <module>()
----> 1 lists = getListsForRunChart(df,spark)
<ipython-input-7-3bc177d0110e> in getListsForRunChart(df, spark)
5 temp_ts=spark.sql("SELECT temperature,ts from washing where temperature is not null order by ts asc")
6 temp_ts_rdd=temp_ts.rdd.sample(False,0.1).map(lambda row:(row.ts,row.temperature))
----> 7 ts=temp_ts_rdd.map(lambda ts,voltage:ts).collect()
8 temperature=temp_ts_rdd.map(lambda ts,voltage:voltage).collect()
9 x=ts,temperature
/opt/ibm/conda/miniconda/lib/python/site-packages/pyspark/rdd.py in collect(self)
887 """
888 with SCCallSiteSync(self.context) as css:
--> 889 sock_info = self.ctx._jvm.PythonRDD.collectAndServe(self._jrdd.rdd())
890 return list(_load_from_socket(sock_info, self._jrdd_deserializer))
891
/opt/ibm/conda/miniconda/lib/python/site-packages/py4j/java_gateway.py in call(self, *args)
1303 answer = self.gateway_client.send_command(command)
1304 return_value = get_return_value(
-> 1305 answer, self.gateway_client, self.target_id, self.name)
1306
1307 for temp_arg in temp_args:
/opt/ibm/conda/miniconda/lib/python/site-packages/pyspark/sql/utils.py in deco(*a, **kw)
126 def deco(*a, **kw):
127 try:
--> 128 return f(*a, **kw)
129 except py4j.protocol.Py4JJavaError as e:
130 converted = convert_exception(e.java_exception)
/opt/ibm/conda/miniconda/lib/python/site-packages/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
326 raise Py4JJavaError(
327 "An error occurred while calling {0}{1}{2}.\n".
--> 328 format(target_id, ".", name), value)
329 else:
330 raise Py4JError(
という結果になってしまい解決方法がわかりません。。。。
あなたの回答
tips
プレビュー