我有这样的查询
test = spark.sql("select mg.moviegenreid, sum(quantity) as total \
from moviegenre mg \
join movie m on m.moviegenreid = mg.moviegenreid \
join detailtransaction dt on dt.movieid = m.movieid \
join headertransaction ht on ht.transactionid = dt.transactionid \
group by mg.moviegenreid \
having sum(quantity) \
order by total desc \
limit 5")
然后我将其插入熊猫数据框
data = test.toPandas()
我只想使用
x = data[{"moviegenreid"}]
y = data[{"total"}
val = pd.DataFrame(data=y,index=x)
val.plot.bar()
我总是会收到这样的错误
ValueError: Index data must be 1-dimensional
答案 0 :(得分:0)
{尝试:
x = data["moviegenreid"]
y = data["total"]
val = pd.DataFrame({'data'=y},index=x)
val.plot.bar()