iT邦幫忙

0

python corr()做地熱圖問題請教

  • 分享至 

  • xImage

您好:
程式碼如下:
要用資料作地熱圖,但df.corr()時出現
ValueError: could not convert string to float: 'ffwind (培)'

資料來源部分資料:
author,pushes,comments,images
ffwind (培),347,681,4
haohao1201 (豪神),1,3,16
Black3831372 (男哥是我),5,7,37
meokay (我可以),5,8,3
maxxxxxx (馬克思),106,115,15
ReiKuromiya (Rei Kuromiya),7,10,4
fack3170 (Jくん),5,7,22

請問,這要如何處理?
謝謝

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt


# 匯入CSV格式的檔案
df = pd.read_csv("pttbeauty2.csv", encoding="utf8")

#sns.pairplot(df, kind="scatter", diag_kind="hist")
#plt.show()

#print( df )


sns.heatmap(df.corr(), annot=True, fmt=".2f")
plt.show()

圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
zivzhong
iT邦研究生 2 級 ‧ 2025-01-23 01:43:27
最佳解答
noway iT邦研究生 1 級 ‧ 2025-01-23 19:15:30 檢舉

您好:
OK
謝謝!

我要發表回答

立即登入回答