在 pandas 上画整行 [英] plot entire row on pandas

查看:36
本文介绍了在 pandas 上画整行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有矩阵中的一整行.我试着做条形图.我试着找任何例子,但我找不到,有人能帮我吗?

I have an entire row from the matrix. And I try to do bar plot.I try to find any examples but I couldn't so, can somebody help me?

In [9]:Atot1
Out[9]: 
     T    G    C   -    A    C    T   -    A    G    T   -    A    G    C   
SAMPLE                                                                          
1       97  457  178  75  718  217  193  69  184  198  777  65  100  143  477   

     -   A   T   G   C  
SAMPLE                      
1       54  63  43  55  47  

推荐答案

选择该行:

row = df.iloc[0]

绘制该行(一个 pandas.Series ):

row.plot(kind='bar')

<小时>

例如,

import pandas as pd
import matplotlib.pyplot as plt

d = {'columns': ['T', 'G', 'C', '-', 'A', 'C', 'T', '-', 'A', 'G', 'T', 
                 '-', 'A', 'G', 'C', '-', 'A', 'T', 'G', 'C'],
     'data': [[97, 457, 178, 75, 718, 217, 193, 69, 184, 198,
               777, 65, 100, 143, 477, 54, 63, 43, 55, 47]],
     'index': [1]}
df = pd.DataFrame(d['data'], columns=d['columns'], index=d['index'])
df.columns.names = ['SAMPLE']

row = df.iloc[0]
row.plot(kind='bar')
plt.show()

收益

这篇关于在 pandas 上画整行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆