我是pyspark的新手,我正在尝试使用一个名为movielens100k的在线公开样本数据集。我通过命令行使用pyspark。
当我尝试创建直方图时,它不会显示。我收到消息“this plugin does not support propagatesizehints()”,然后当我再次尝试该命令以显示直方图时,什么也没有发生。没有错误,没有输出或任何东西。这是我的密码:
>>> import numpy
>>> import pandas
>>> import sklearn
>>> import os
>>> os.environ['QT_QPA_PLATFORM']='offscreen'
>>> import matplotlib.pyplot
>>> user_data = sc.textFile("...../ml-100k/u.user")
>>> user_fields = user_data.map(lambda line: line.split("|"))
>>> ages = user_fields.map(lambda x: int(x[1])).collect()
>>> import pylab
>>> pylab.hist(ages, bins=20, color='lightblue', normed=True)
这是此时的输出:
QFontDatabase: Cannot find font directory
/var/hadoop/anaconda2/lib/fonts - is Qt installed correctly?
QFontDatabase: Cannot find font directory
/var/hadoop/anaconda2/lib/fonts - is Qt installed correctly?
QFontDatabase: Cannot find font directory
/var/hadoop/anaconda2/lib/fonts - is Qt installed correctly?
QFontDatabase: Cannot find font directory
/var/hadoop/anaconda2/lib/fonts - is Qt installed correctly? (array([
0.00064269, 0.00192808, 0.00449886, 0.0279572 , 0.02956393,
0.03374144, 0.04563129, 0.02538642, 0.02088756, 0.01863813,
0.02088756, 0.01606735, 0.0170314 , 0.01863813, 0.00674829,
0.00482021, 0.0054629 , 0.00192808, 0.00128539, 0.00128539]), array([ 7. , 10.3, 13.6, 16.9, 20.2, 23.5, 26.8, 30.1, 33.4,
36.7, 40. , 43.3, 46.6, 49.9, 53.2, 56.5, 59.8, 63.1,
66.4, 69.7, 73. ]), <a list of 20 Patch objects>)
当我尝试渲染图形时,会发生以下情况:
>>> fig = matplotlib.pyplot.gcf()
>>> fig.set_size_inches(16, 10)
>>> fig.show()
This plugin does not support propagateSizeHints()
>>> fig.show()
>>>
请让我知道如何解决这个问题,使直方图出现。谢谢!
暂无答案!
目前还没有任何答案,快来回答吧!