您好,我正在使用IBM Bluemix。 在这里,我使用的是Apache Spark笔记本,并从dashDB加载数据。我试图提供一个可视化,它不显示行,只是列。如何在Python中使用熊猫火花笔记本(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)
当我使用这个命令:
data_df.take(5)
我得到的第一个5列列和行数据信息。 但是,当我这样做:
content_string = get_file_content(credentials)
BATTLES_df = pd.read_table(content_string)
我得到这个错误:
ValueError: No columns to parse from file
,然后当我尝试看看.head()
或.tail()
仅显示列名。
有没有人在这里看到可能的问题?我对python的知识很差。谢谢,麻烦您了。