날짜 및 시간 인 인덱스를 x 축으로 사용하여 팬더 데이터 프레임에 데이터를 플롯하려고합니다. 나머지 데이터는 데이터 프레임에 실제 데이터로 저장됩니다.matplotlib에서 x 축으로 사용할 팬더 데이터 프레임에서 날짜 인덱스를 가져 오는 방법
from matplotlib.finance import candlestick2
bars[['open','high','low','close']].head()
tickdatetime open high low close
2012-09-20 09:00:00 1447.50 1447.50 1447.00 1447.00
2012-09-20 09:01:00 1447.00 1447.25 1447.00 1447.25
2012-09-20 09:02:00 1447.25 1447.75 1447.25 1447.50
2012-09-20 09:03:00 1447.75 1447.75 1447.25 1447.50
2012-09-20 09:04:00 1447.25 1447.50 1447.25 1447.50
fig,ax = plt.subplots()
ax.plot_date(bars.ix.to_pydatetime(), s, 'v-')
fig,ax = plt.subplots()
ax.plot_date(bars.ix.to_pydatetime(), s, 'v-')
ax = fig.add_axes([0.1, 0.2, 0.85, 0.7])
ax.autoscale_view()
linecol, rectcol = candlestick2(ax,bars['open'],bars['close'],bars['high'],bars['low'],width=.5,colorup='g',colordown''r',alpha=1)
z = rectcol.get_zorder()
linecol.set_zorder(0.9*z)
하지만 난이 오류 : 여기에 지금 노력하고 무엇
AttributeError Traceback (most recent call last)
<ipython-input-57-d62385067ceb> in <module>()
1 fig,ax = plt.subplots()
----> 2 ax.plot_date(bars.ix.to_pydatetime(), s, 'v-')
3
4 #ax = fig.add_axes([0.1, 0.2, 0.85, 0.7])
5 ax.autoscale_view()
AttributeError: '_NDFrameIndexer' object has no attribute 'to_pydatetime'
나는 (그 bars.plot 이해가)이 작업을 자동으로 처리 할 수있는 좋은 인터페이스입니다하지만 난 원하는
내 문제의 루트는 데이터 프레임에서 인덱스 값을 가져 와서 인덱스 값을 datetimes로 변환하려고하는 것 같지만 아직 그 일을 할 수 없었다.
모든 아이디어를 높이 평가합니다!
bars.ix 대신 bars.index를 사용해야합니다. –