【发布时间】:2017-02-17 15:47:03
【问题描述】:
给定数据:
Column1; Column2; Column3
1; 4; 6
2; 2; 6
3; 3; 8
4; 1; 1
5; 4; 2
我可以通过以下方式绘制它:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('test0.csv',delimiter='; ', engine='python')
titles = list(df)
for title in titles:
if title == titles[0]:
continue
df.plot(titles[0],title, linestyle='--', marker='o')
plt.savefig(title+'.png')
但如果相反,数据丢失了Column1,例如:
Column2; Column3
4; 6
2; 6
3; 8
1; 1
4; 2
如何绘制它?
可能是df.plot(title, linestyle='--', marker='o')?
【问题讨论】:
-
有很多方法来绘制它!我需要更好地了解您要绘制的内容。
-
我想绘制
Column2 X index,但缺少索引。 -
@KcFnMi,IIUC,您可以执行
reset_index将DF的索引设置为默认整数索引,然后将Column2作为绘图的y arg 传递为:@987654330 @
标签: python python-2.7 pandas matplotlib dataframe