你好,我用的是IBM Bluemix。 这里我使用的是apachespark笔记本,并从dashDB加载数据 我试图提供一个可视化,它不显示行,只显示列。在
def get_file_content(credentials):
from pyspark.sql import SQLContext
sqlContext = SQLContext(sc)
props = {}
props['user'] = credentials['username']
props['password'] = credentials['password']
# fill in table name
table = credentials['username'] + "." + "BATTLES"
data_df=sqlContext.read.jdbc(credentials['jdbcurl'],table,properties=props)
data_df.printSchema()
return StringIO.StringIO(data_df)
使用此命令时:
^{pr2}$我得到前5行数据的信息,其中包括列和行。 但当我这么做的时候:
content_string = get_file_content(credentials)
BATTLES_df = pd.read_table(content_string)
我得到这个错误:
ValueError: No columns to parse from file
然后当我试图查看.head()
或.tail()
时,只显示列名。在
有人看到可能的问题吗?我对python很不了解。谢谢你。在
这是对我有效的解决方案。 我换了
BATTLES_df = pd.read_table(content_string)
与
BATTLES_df=data_df.toPandas()
谢谢你
去你的星火目录
^{pr2}$你可以写下面的代码。在
相关问题 更多 >
编程相关推荐