[英]Select specific column from multiple dataframe to combine into one dataframe pandas
[英]How to select multiple specific values from a column in dataframe for plotting
我有一個 DataFrame,其中包含一個名為“Label”的分類數據列。 這是 df.Label.value_counts() 代碼的輸出。
O 382963
B-protein 30269
I-protein 24848
I-DNA 15774
B-DNA 9533
I-cell_type 8748
I-cell_line 7387
B-cell_type 6718
B-cell_line 3830
I-RNA 1530
B-RNA 951
我想使用 seaborn 庫中的 countplot() 來繪制這些值,但我只想繪制 B-label 值的計數,而不是 Label 列中的所有值。
我試過這個
sns.countplot(x=df.Label, data=df[-(df.Label == 'I-Protein')])
它僅適用於 I-Protein 標簽。 然后我嘗試減去其他特定值,但沒有用。 例如我試過這個:
sns.countplot(x=df.Label, data=df[-(df.Label == 'I-Protein' or 'I-DNA'])
這是一個失敗。
有人能幫我嗎? 謝謝你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.