[英]Seaborn error with kde plot: The following variable cannot be assigned with wide-form data `hue`
我有一個 pandas dataframe df
有兩列( type
和IR
)作為這個:
type IR
0 a 0.1
1 b 0.3
2 b 0.2
3 c 0.8
4 c 0.5
...
我想要 plot 三個分布(每個type
一個)與 IR 的值所以,我寫:
sns.displot(df, kind="kde", hue='type', rug=True)
但我收到此錯誤: The following variable cannot be assigned with wide-form data 'hue'
任何的想法?
編輯:
我真正的 dataframe 看起來像
pd.DataFrame({"type": ["IR orig", "IR orig", "IR orig", "IR trans", "IR trans", "IR trans", "IR perm", "IR perm", "IR perm", "IR perm", "IR perm"],
"IR": [1.41, 1.42, 1.32, 0.0, 0.44, 0.0, 1.41, 1.31, 1.41, 1.37, 1.34]
})
但是使用sns.displot(df, x='IR', kind="kde", hue='type', rug=True)
我得到了ValueError: cannot reindex on an axis with duplicate labels
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.