Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python-从数据帧创建2线图_Python_Python 2.7_Pandas_Matplotlib_Dataframe - Fatal编程技术网

Python-从数据帧创建2线图

Python-从数据帧创建2线图,python,python-2.7,pandas,matplotlib,dataframe,Python,Python 2.7,Pandas,Matplotlib,Dataframe,我正在尝试从我的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.637

我正在尝试从我的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
它总共有51行,但我只是复制了前10行以保持可读性。我知道如何从pandas数据帧制作简单的线图,但现在我想做以下工作:

我想要一个X轴上有日期的线图,在我的图中有两条线,一条用于“interrupts\u person”列,另一条用于“interrupts\u Mean”列。 如果有人对如何制作这样的折线图很熟悉,我真的非常感谢能有人帮助我继续进步

瞧,我的朋友

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

20122013-100-3代表什么时间?假设20122013是dmY,但100-3没有意义。Pandas to_datetime将无法将其转换为有效格式