-1
我想從由couchdb形成的pandas dataframe列繪製數據。這是什麼樣的代碼和輸出數據:Seaborn地塊kdeplot但不是distplot
print df4.Patient_Age
Doc_ID
000103f8-7f48-4afd-b532-8e6c1028d965 99
00021ec5-9945-47f7-bfda-59cf8918f10b 92
0002510f-fb89-11e3-a6eb-742f68319ca7 32
00025550-9a97-44a4-84d9-1f6f7741f973 73
0002d1b8-b576-4db7-af55-b3f26f7ca63d 49
0002d40f-2b45-11e3-8f66-742f68319ca7 42
000307eb-18a6-47cd-bb03-33e484fad029 18
00033d3d-1345-4739-9522-b41b8db3ee23 42
00036d2e-0a51-4cfb-93d1-3e137a026f19 42
0003b054-5f3b-4553-8104-f71d7a940d84 10
Name: Patient_Age, dtype: object
如果我執行此代碼:
sns.kdeplot(df4.Patient_Age)
預期該地塊產生。然而,當我運行此:
sns.distplot(df4.Patient_Age)
我碰到下面的錯誤與distplot:
TypeError: unsupported operand type(s) for /: 'unicode' and 'long'
要糾正這個錯誤,我用:
df4.Patient_Age = [int(i) for i in df4.Patient_Age]
all(isinstance(item,int) for item in df4.Patient_Age)
輸出是:
False
我想要的是什麼t和是:
- 爲什麼被先前生成的kdeplot但不是histplot?
- 當我將數據類型更改爲
int
時,爲什麼仍然得到False
?如果數據不是int
(如False
所示),那麼histplot
爲什麼在轉換後有效?
請給我們一個[MCVE。 – cel