sparksql_可视化组分布_histogram

sparksql_可视化组分布_histogram
可参考:
https://blog.csdn.net/weixin_39599711/article/details/79072691

# 如果数据是几百万行,第二种方法显然不可取。因此需要先聚合数据。
hists = fraud_df.select('balance').rdd.flatMap(lambda row: row).histogram(20)
To plot the histogram you can simply call the matplotlib like below.

# 绘图:
data = {
    'bins': hists[0][:-1],
    'freq': hists[1]
}
​
fig = plt.figure(figsize=(12,9))
ax = fig.add_subplot(1, 1, 1)
ax.bar(data['bins'], data['freq'], width=2000)
ax.set_title('Histogram of \'balance\'')
​
plt.savefig('B05793_05_22.png', dpi=300)

在这里插入图片描述

发布了273 篇原创文章 · 获赞 1 · 访问量 4692

猜你喜欢

转载自blog.csdn.net/wj1298250240/article/details/103947070
今日推荐