datascience learning summary 01

Error summary

Error summary

… object is not subscriptable

TypeError                                 Traceback (most recent call last)
<ipython-input-216-ca85a32d972d> in <module>
     12         return -1
     13     return 0
---> 14 profit(pd.to_datetime('2018-01-06'))

<ipython-input-216-ca85a32d972d> in profit(mdate)
      6     today = pfyh['date'].iloc[-1]
      7     yesday = pfyh['date'].iloc[-2]
----> 8     tma5,tma10,yma5,yma10=today['ma5'],today['ma10'],yesday['ma5'],yesday['ma10']
      9     if (yma10>yma5) and (tma10<=tma5):
     10         return 1

TypeError: 'Timestamp' object is not subscriptable

subscript: write below; subscript. The timestamp object cannot be subscripted.
pfyh['date'] gets a timestamp, this place should be checked and modified.

Guess you like

Origin blog.csdn.net/weixin_52377146/article/details/113094963