AI4Finance-Foundation / AI4Finance-Foundation/FinRL

Problem in Stock_NeurlPS2018_3_Backtest Mean Variance Optimization - Panda 2.0.0 issue

Đang mở
#984 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Jupyter Notebook
Star
16.3k
Fork
3.5k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Going through part 3 of the Tutorials, when I am creating the Mean Variance Optimization, switched to Pandas 1.5.3 and no issue, just reporting possible incompatibility w/ Pandas 2.0.0

Python 3.9.16
Pandas 2.0.0

I am getting the following errors from this cell:

StockData = process_df_for_mvo(train)
TradeData = process_df_for_mvo(trade)

TradeData.to_numpy()

KeyError: "None of [Index(['2009-01-02', '2009-01-02', '2009-01-02', '2009-01-02', '2009-01-02',\n '2009-01-02', '2009-01-02', '2009-01-02', '2009-01-02', '2009-01-02',\n '2009-01-02', '2009-01-02', '2009-01-02', '2009-01-02', '2009-01-02',\n '2009-01-02', '2009-01-02', '2009-01-02', '2009-01-02', '2009-01-02',\n '2009-01-02', '2009-01-02', '2009-01-02', '2009-01-02', '2009-01-02',\n '2009-01-02', '2009-01-02', '2009-01-02', '2009-01-02'],\n dtype='object')] are in the [index]

Traceback:
KeyError Traceback (most recent call last)
Cell In[21], line 1
----> 1 StockData = process_df_for_mvo(train)
2 TradeData = process_df_for_mvo(trade)
4 TradeData.to_numpy()

Cell In[19], line 16, in process_df_for_mvo(df)
14 n = n.iloc[i * stock_dimension:(i+1) * stock_dimension, :]
15 date = n['date'][i*stock_dimension]
---> 16 mvo.loc[date] = n['close'].tolist()
18 return mvo

File /home/user/anaconda3/envs/FinRL/lib/python3.9/site-packages/pandas/core/indexing.py:845, in _LocationIndexer.__setitem__(self, key, value)
843 else:
844 key = com.apply_if_callable(key, self.obj)
--> 845 indexer = self._get_setitem_indexer(key)
846 self._has_valid_setitem_indexer(key)
848 iloc = self if self.name == "iloc" else self.obj.iloc

File /home/user/anaconda3/envs/FinRL/lib/python3.9/site-packages/pandas/core/indexing.py:716, in _LocationIndexer._get_setitem_indexer(self, key)
712 if isinstance(key, range):
713 # GH#45479 test_loc_setitem_range_key
714 key = list(key)
--> 716 return self._convert_to_indexer(key, axis=0)
...
-> 5935 raise KeyError(f"None of [{key}] are in the [{axis_name}]")
5937 not_found = list(ensure_index(key)[missing_mask.nonzero()[0]].unique())
5938 raise KeyError(f"{not_found} not in index")

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.