我在分析中使用两个Jupyter笔记本来做不同的事情.在我的Scala笔记本中,我将一些已清理的数据写入镶木地板:
partitionedDF.select("noStopWords","lowerText","prediction").write.save("swift2d://xxxx.keystone/commentClusters.parquet")
Run Code Online (Sandbox Code Playgroud)
然后我去我的Python笔记本读取数据:
df = spark.read.load("swift2d://xxxx.keystone/commentClusters.parquet")
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
AnalysisException: u'Unable to infer schema for ParquetFormat at swift2d://RedditTextAnalysis.keystone/commentClusters.parquet. It must be specified manually;'
Run Code Online (Sandbox Code Playgroud)
我查看了spark文档,我认为不应该要求我指定一个模式.有没有人碰到这样的事情?我保存/加载时应该做些什么吗?数据将在对象存储中登陆.
编辑:我在读取和写入时都会唱出spark 2.0.
edit2:这是在Data Science Experience的一个项目中完成的.
我正在尝试访问我的 Watson Data Platform 目录中的 csv 文件。我使用了 DSX 笔记本中的代码生成功能:Insert to code> Insert StreamingBody object。
生成的代码是:
import os
import types
import pandas as pd
import boto3
def __iter__(self): return 0
# @hidden_cell
# The following code accesses a file in your IBM Cloud Object Storage. It includes your credentials.
# You might want to remove those credentials before you share your notebook.
os.environ['AWS_ACCESS_KEY_ID'] = '******'
os.environ['AWS_SECRET_ACCESS_KEY'] = '******'
endpoint = 's3-api.us-geo.objectstorage.softlayer.net'
bucket = 'catalog-test'
cos_12345 = boto3.resource('s3', endpoint_url=endpoint) …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 IBM Watson Studio 连接到 COS,但出现错误...
当我按 Enter 时,出现以下错误:
Unable to find products data_catalog or data_science_experience in the
entitlements response for account id: 51373fa1b8bf36fd9d78574d19af0d11.
Run Code Online (Sandbox Code Playgroud) ibm-watson data-science-experience ibm-cloud-storage watson-studio
该Insert to Code功能使您能够在 Watson Studio 中的 Jupyter 笔记本中工作时访问存储在 Cloud Object Storage 中的数据。某些文件类型(例如 txt 文件)将只有 StreamingBody 和 Credentials 作为插入代码选项:
如何使用StreamingBody对象访问我的数据?
pandas jupyter-notebook data-science-experience watson-studio
我正在尝试从DSX Python笔记本中将pandas数据帧作为CSV写入Bluemix对象存储.我首先将数据帧保存为"本地"CSV文件.然后我有一个例程尝试将文件写入对象存储.我得到413响应 - 对象太大了.该文件只有大约3MB.这是我的代码,基于我在这里找到的JSON示例:http://datascience.ibm.com/blog/working-with-object-storage-in-data-science-experience-python-edition/
import requests
def put_file(credentials, local_file_name):
"""This function writes file content to Object Storage V3 """
url1 = ''.join(['https://identity.open.softlayer.com', '/v3/auth/tokens'])
data = {'auth': {'identity': {'methods': ['password'],
'password': {'user': {'name': credentials['name'],'domain': {'id': credentials['domain']},
'password': credentials['password']}}}}}
headers = {'Content-Type': 'text/csv'}
with open(local_file_name, 'rb') as f:
resp1 = requests.post(url=url1, data=f, headers=headers)
return resp1
Run Code Online (Sandbox Code Playgroud)
非常感谢任何帮助或指示.
我在IBM Data Science Experience上使用 Jupyter Notebook 。是否可以启用SQL Magics/IPython-sql?我该如何安装?
我想连接到 dashDB/DB2 并运行 SQL 语句。
db2 dashdb jupyter-notebook data-science-experience ibm-cloud
我正在尝试使用以下notebook命令安装nltk:
!pip install nltk
Run Code Online (Sandbox Code Playgroud)
但是,这会引发以下错误:
error: could not create '/usr/local/src/bluemix_ipythonspark_141/notebook/lib/python2.7/site-packages/nltk':
Permission denied
Run Code Online (Sandbox Code Playgroud)
如何从Jupyter笔记本安装nltk?请注意,bluemix上的spark环境只能通过笔记本访问.她无法进入环境.
在Python笔记本中,我可以执行!pip freeze以获取已安装软件包的列表.但结果是一个空列表,或者只显示我自己安装的几个包.几周前,该命令将返回所有软件包的列表,包括IBM预安装的软件包.我怎样才能获得完整列表?
python apache-spark data-science-experience ibm-cloud watson-studio
你能帮我说明如何为 IBM 的数据科学体验中的 PySpark 会话设置检查点目录吗?。
需要是因为我必须connectedComponents()从 GraphFrames运行它会引发以下错误
Py4JJavaError: An error occurred while calling o221.run.
: java.io.IOException: Checkpoint directory is not set. Please set it first using sc.setCheckpointDir().
Run Code Online (Sandbox Code Playgroud) 我正在尝试tm在IBM的数据科学体验(DSX)上安装该软件包:
install.packages("tm")
Run Code Online (Sandbox Code Playgroud)
但是,我正在解决这个问题:
"dependency 'slam' is not available"
Run Code Online (Sandbox Code Playgroud)
这篇文章表明R版本3.3.1 will解决了这个问题,但是DSX上的R版本是:R version 3.3.0 (2016-05-03)
如何在IBM DSX上解决此问题?请注意,您在DSX上没有root访问权限.
我在stackoverflow上看到了类似的问题,但没有人问如何解决IBM DSX上的问题,例如在安装TM软件包时依赖'slam'不可用
更新:
install.packages("slam")
Run Code Online (Sandbox Code Playgroud)
返回:
Installing package into '/gpfs/global_fs01/sym_shared/YPProdSpark/user/s85d-88ebffb000cc3e-39ca506ba762/R/libs'
(as 'lib' is unspecified)
Warning message:
"package 'slam' is not available (for R version 3.3.0)"
Run Code Online (Sandbox Code Playgroud)