亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

保存pandas dataframe head(5)、統計、plot為圖片輸出

保存pandas dataframe head(5)、統計、plot為圖片輸出

楊魅力 2023-02-22 16:49:02
有什么辦法可以將它們另存為 png 或其他圖像輸出嗎?輸出圖像需要包括:df.head(5)df[column].describe()distribution plotor histogram plot(或任何其他情節......)
查看完整描述

1 回答

?
猛跑小豬

TA貢獻1858條經驗 獲得超8個贊

這是您要實現的目標的示例:


fig, ax = plt.subplots(2, 2, figsize=(20, 10))


# hide axes

# fig.patch.set_visible(False)

ax[0][0].axis('off')

ax[0][1].axis('off')

ax[0][1].axis('tight')

ax[0][0].axis('tight')


df = pd.DataFrame(np.random.rand(10, 4), columns=list('ABCD'))


ax[0][0].table(cellText=df.head().values, colLabels=df.columns, loc='center')

ax[0][1].table(cellText=df.describe().values, colLabels=df.describe().columns, rowLabels=df.describe().index, loc='center')


df.plot(kind='hist', ax=ax[1][0])

df.plot(kind='box', ax=ax[1][1])


fig.tight_layout()


plt.show()

http://img1.sycdn.imooc.com//63f5d9480001481914380719.jpg

查看完整回答
反對 回復 2023-02-22
  • 1 回答
  • 0 關注
  • 235 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號