pandas 在熊猫上绘制整行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32105817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 23:47:22 来源:igfitidea点击:
plot entire row on pandas
提问by kant
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
回答by unutbu
Select the row:
选择行:
row = df.iloc[0]
Plot the row (a pandas.Series):
绘制行 (a pandas.Series):
row.plot(kind='bar')
For example,
例如,
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()
yields
产量


