请看一下图片。
我一直试图自己解决这个问题,但不幸的是我没有成功。 我基本上想要采用以下格式:
close1 close2
date x x
x x
***code***
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
from pandas import Series, DataFrame
import ystockquote
#eon
his1 = ystockquote.get_historical_prices('EOAN.DE', '2013-01-01', '2013-01-10')
eon = DataFrame(his1)
close_eon = eon.ix["Close"]
#RWE
his2 = ystockquote.get_historical_prices('RWE.DE', '2013-01-01', '2013-01-10')
rwe = DataFrame(his2)
close_rwe = rwe.ix["Close"]
fig = plt.figure(); ax = fig.add_subplot(1,1,1)
ax.plot(close_eon)
ax.plot(close_rwe)
plt.show()
eonrwe = eon.append(rwe)
答案 0 :(得分:4)
你能连接close
系列吗?
import matplotlib.pyplot as plt
import pandas as pd
import pandas.io.data as web
start = pd.datetime(2013, 1, 1)
end = pd.datetime(2013, 1, 10)
eon = web.DataReader("EOAN.DE", 'yahoo', start, end)
rwe = web.DataReader("RWE.DE", 'yahoo', start, end)
closes = pd.concat({ "eon" : eon["Close"], "rwe" : rwe["Close"]}, axis=1)
closes.plot()
给出
eon rwe
2013-01-01 14.09 31.24
2013-01-02 14.35 31.61
2013-01-03 14.40 31.53
2013-01-04 14.51 31.90
2013-01-07 14.26 30.93
2013-01-08 14.22 30.95
2013-01-09 14.40 31.30
2013-01-10 14.35 30.70