您好,我正在使用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的知識很差。謝謝,麻煩您了。