简体   繁体   English

Python-从pandas DataFrame创建2个折线图

[英]Python - Create 2 line graph from pandas DataFrame

I am trying to create a line graph from my Pandas Dataframe. 我正在尝试从Pandas Dataframe创建折线图。 The Pandas Dataframe I have looks as follows: 我的Pandas数据框如下所示:

    date    Interrupts_Person   Interrupts_Mean
0   20122013-100-3  0   11.727273
1   20122013-100-6  1   5.428571
2   20122013-17-6   6   8.900000
3   20122013-17-9   0   4.062500
4   20122013-21-4   4   5.637931
5   20122013-22-8   0   5.637931
6   20122013-3-8    0   4.846154
7   20122013-32-6   0   2.727273
8   20122013-32-6   0   2.727273
9   20122013-48-23  0   4.875000
10  20122013-48-23  0   4.875000

It is in total having 51 lines but i just copied the first 10 to keep things readable.I know how to make a simple line graph from a pandas dataframe, but now i want to do the following: 总共有51条线,但我只是复制了前10条以保持可读性。我知道如何从pandas数据帧制作简单的线图,但现在我想执行以下操作:

I want a line graph with the date on the X-axis and 2 lines in my graph, one for the column 'interrupts_person' and one for the column 'Interrupts_Mean'. 我想要一个在X轴上带有日期的折线图,在我的图中有2条线,一条用于“ interrupts_person”列,另一条用于“ Interrupts_Mean”列。 If someone is familliar on how to make a line-graph like thism I would be realy thankfull for some help that continues my progress! 如果有人熟悉如何制作这样的线图,我将非常感谢您为我的进步提供的帮助!

voila mon ami 瞧阿米

df['date'] = pd.to_datetime(df['date'])
df.set_index('date', inplace = True)
df[['interrupts_person','Interrupts_Mean']].plot(secondary_y = 'Interrupts_Mean')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM