首先,我下面有2个数据帧:
var Telnet = global.get('telnetModule')
var connection = new Telnet()
var params = {
host: '192.168.100.100',
port: 23,
shellPrompt: '',
timeout: 5000,
}
connection.on('connect', function() {
console.log('connecting......');
})
connection.on('ready', function() {
console.log('ready!')
})
connection.on('timeout', function() {
console.log('socket timeout!')
connection.end()
})
connection.connect(params);
我想用import pandas as pd
df1= {
'date' : [
'2019-03-25 19:56:29.332874+00:00',
'2019-03-25 20:39:55.958678+00:00',
'2019-03-25 20:40:38.057880+00:00'
],
'status' : ['buy', 'sell' ,'buy'],
'price' : ['15', '17' ,'16'],
}
df2= {
'date' : [
'2019-03-25 19:00:00',
'2019-03-25 19:30:00',
'2019-03-25 20:00:00',
'2019-03-25 20:30:00',
'2019-03-25 21:00:00'
],
'price' : ['13', '12' ,'16', '14', '18']
}
df1 = pd.DataFrame(df1)
df1 ['date'] = df1 ['date'].astype('datetime64')
df2 = pd.DataFrame(df2)
df2['date'] = df2['date'].astype('datetime64')
绘制折线图,并根据日期和价格在df2
图的顶部标记df1
。我可以简单地使用这一行代码来绘制折线图。
df2
现在,如何在上图上方标记plt.plot(df2,'b-')
的价格?
我不介意使用seaborn,matplotlib或其他任何工具。
谢谢。