[英]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.