如何在 azure databricks 中导出我的预测(数组)?
How do I export my prediction(array) in the azure databricks?
我无法将我的数据框导出到 csv。留言"CSV data source does not support array"
predictions.write.option("delimiter", "\t").csv("/mnt/classification2018/testpredic2")
我试过这个命令但是连接了,但是没有成功
from pyspark.sql.functions import concat_ws
predictions.withColumn("probability", concat_ws(",", "probability")).show()
日志错误
/databricks/spark/python/pyspark/sql/utils.py in deco(*a, **kw)
61 def deco(*a, **kw):
62 try:
---> 63 return f(*a, **kw)
64 except py4j.protocol.Py4JJavaError as e:
65 s = e.java_exception.toString()
/databricks/spark/python/lib/py4j-0.10.7-src.zip/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(
Py4JJavaError: An error occurred while calling o1472.csv.
: java.lang.UnsupportedOperationException: CSV data source does not support array<string> data type.
at org.apache.spark.sql.execution.datasources.csv.CSVUtils$.org$apache$spark$sql$execution$datasources$csv$CSVUtils$$verifyType(CSVUtils.scala:127)
将列转换为字符串并写入 csv
from pyspark.sql.functions import col
predictions = predictions.withColumn("probability", col("probability").cast("string))
predictions.write.option("delimiter", "\t").csv("/mnt/classification2018/testpredic2")
我无法将我的数据框导出到 csv。留言"CSV data source does not support array"
predictions.write.option("delimiter", "\t").csv("/mnt/classification2018/testpredic2")
我试过这个命令但是连接了,但是没有成功
from pyspark.sql.functions import concat_ws
predictions.withColumn("probability", concat_ws(",", "probability")).show()
日志错误
/databricks/spark/python/pyspark/sql/utils.py in deco(*a, **kw)
61 def deco(*a, **kw):
62 try:
---> 63 return f(*a, **kw)
64 except py4j.protocol.Py4JJavaError as e:
65 s = e.java_exception.toString()
/databricks/spark/python/lib/py4j-0.10.7-src.zip/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(
Py4JJavaError: An error occurred while calling o1472.csv.
: java.lang.UnsupportedOperationException: CSV data source does not support array<string> data type.
at org.apache.spark.sql.execution.datasources.csv.CSVUtils$.org$apache$spark$sql$execution$datasources$csv$CSVUtils$$verifyType(CSVUtils.scala:127)
将列转换为字符串并写入 csv
from pyspark.sql.functions import col
predictions = predictions.withColumn("probability", col("probability").cast("string))
predictions.write.option("delimiter", "\t").csv("/mnt/classification2018/testpredic2")