logo
Loading...

part3 更新後出現 Index error (附上詳細訊息)? - Cupoy

/content/cstock.py in predict_result(trading_param...

part3 更新後出現 Index error (附上詳細訊息)?

2020/10/30 下午 06:18
AI股票交易技術討論版
Jack Wu
觀看數:15
回答數:3
收藏數:0

/content/cstock.py in predict_result(trading_params, model_d1, model_d60)1324 return_df = return_df[return_df['代號'].isin(keep_list)]1325 return_df = pd.merge(return_df, asset_df, on=['代號'], how='outer')-> 1326 query_df = asset_query(set(return_df['代號'])-{'現金'})[['代號', '最新收盤', '最新漲跌']]1327 return_df = pd.merge(return_df, query_df, on=['代號'], how='left')1328

/content/cstock.py in asset_query(query_set)1103 data = df[df['代號']==stock_id]1104 data = data.iloc[-2:]-> 1105 last_date = data['日期'].iloc[-1]1106 last_close = data['收盤'].iloc[-1]1107 prev_close = data['收盤'].iloc[-2]

/usr/local/lib/python3.6/dist-packages/pandas/core/indexing.py in getitem(self, key)877878 maybe_callable = com.apply_if_callable(key, self.obj)--> 879 return self._getitem_axis(maybe_callable, axis=axis)880881 def _is_scalar_access(self, key: Tuple):

/usr/local/lib/python3.6/dist-packages/pandas/core/indexing.py in _getitem_axis(self, key, axis)14941495 # validate the location-> 1496 self._validate_integer(key, axis)14971498 return self.obj._ixs(key, axis=axis)

/usr/local/lib/python3.6/dist-packages/pandas/core/indexing.py in _validate_integer(self, key, axis)1435 len_axis = len(self.obj._get_axis(axis))1436 if key >= len_axis or key < -len_axis:-> 1437 raise IndexError("single positional indexer is out-of-bounds")14381439 # -------------------------------------------------------------------

回答列表

  • 2020/11/05 上午 02:59
    張維元 (WeiYuan)
    贊同數:0
    不贊同數:1
    留言數:0

    我覺得你沒有提供到好讀的資訊,你要不要用截圖的比較快,通常錯誤訊息的最下面有紅字的部分是重要的。


    很高興可以在這次問答進行討論,如果還有不懂或是模糊的部分也歡迎持續追問。期待你的互動與鼓勵創造出不同更深度的討論。歡迎加入我自己經營的Line 群組社群,會有不定時舉辦的分享活動,一起來玩玩吧!

  • 2020/11/11 上午 11:12
    CUPOY
    贊同數:0
    不贊同數:0
    留言數:1

    同學 您好,


    以上問題,目前專家正在處理此程序,我們會第一時間回覆您,謝謝您。

  • 2020/11/14 下午 00:25
    Jack Wu
    贊同數:0
    不贊同數:0
    留言數:0