Closed DuongNhatThanh closed 3 months ago
Tôi gặp phải lỗi "Length mismatch: Expected axis has 4 elements, new values have 12 elements" khi chạy đoạn code sau: "import vnquant.data as dt START = "2018-01-10" TODAY = "2018-02-15" loader = dt.DataLoader(symbols="VND", start=START, end=TODAY, minimal=True, data_source="cafe")
Download the data using the loader
data = loader.download()
Display the data as a Pandas DataFrame
print(data)". Đây là full output: " data = loader.download() ^^^^^^^^^^^^^^^^^ File "C:\Users\duong\anaconda3\Lib\site-packages\vnquant-0.1.1-py3.11.egg\vnquant\data\dataloader.py", line 36, in download stock_data = loader.download() ^^^^^^^^^^^^^^^^^ File "C:\Users\duong\anaconda3\Lib\site-packages\vnquant-0.1.1-py3.11.egg\vnquant\data\dataloader.py", line 231, in download stock_datas.append(self.download_one(symbol)) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\duong\anaconda3\Lib\site-packages\vnquant-0.1.1-py3.11.egg\vnquant\data\dataloader.py", line 242, in download_one stock_slice_batch = self.download_batch(i + 1, symbol) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\duong\anaconda3\Lib\site-packages\vnquant-0.1.1-py3.11.egg\vnquant\data\dataloader.py", line 295, in download_batch stock_slice_batch.columns = ['date', 'adjust', 'close', 'change_perc', 'avg', ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\duong\anaconda3\Lib\site-packages\pandas\core\generic.py", line 5915, in setattr return object.setattr(self, name, value) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "pandas_libs\properties.pyx", line 69, in pandas._libs.properties.AxisProperty.set File "C:\Users\duong\anaconda3\Lib\site-packages\pandas\core\generic.py", line 823, in _set_axis self._mgr.set_axis(axis, labels) File "C:\Users\duong\anaconda3\Lib\site-packages\pandas\core\internals\managers.py", line 230, in set_axis self._validate_set_axis(axis, new_labels) File "C:\Users\duong\anaconda3\Lib\site-packages\pandas\core\internals\base.py", line 70, in _validate_set_axis raise ValueError( ValueError: Length mismatch: Expected axis has 4 elements, new values have 12 elements".
cái này sửa data_source="cafe" thành data_source="vnd" là chạy được ạ
Bạn pull code mới nhất về nhé. Mình đã cập nhật lại các API cũ cho tất cả các nguồn lấy dữ liệu chứng khoán.
Tôi gặp phải lỗi "Length mismatch: Expected axis has 4 elements, new values have 12 elements" khi chạy đoạn code sau: "import vnquant.data as dt START = "2018-01-10" TODAY = "2018-02-15" loader = dt.DataLoader(symbols="VND", start=START, end=TODAY, minimal=True, data_source="cafe")
Download the data using the loader
data = loader.download()
Display the data as a Pandas DataFrame
print(data)". Đây là full output: " data = loader.download() ^^^^^^^^^^^^^^^^^ File "C:\Users\duong\anaconda3\Lib\site-packages\vnquant-0.1.1-py3.11.egg\vnquant\data\dataloader.py", line 36, in download stock_data = loader.download() ^^^^^^^^^^^^^^^^^ File "C:\Users\duong\anaconda3\Lib\site-packages\vnquant-0.1.1-py3.11.egg\vnquant\data\dataloader.py", line 231, in download stock_datas.append(self.download_one(symbol)) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\duong\anaconda3\Lib\site-packages\vnquant-0.1.1-py3.11.egg\vnquant\data\dataloader.py", line 242, in download_one stock_slice_batch = self.download_batch(i + 1, symbol) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\duong\anaconda3\Lib\site-packages\vnquant-0.1.1-py3.11.egg\vnquant\data\dataloader.py", line 295, in download_batch stock_slice_batch.columns = ['date', 'adjust', 'close', 'change_perc', 'avg', ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\duong\anaconda3\Lib\site-packages\pandas\core\generic.py", line 5915, in setattr return object.setattr(self, name, value) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "pandas_libs\properties.pyx", line 69, in pandas._libs.properties.AxisProperty.set File "C:\Users\duong\anaconda3\Lib\site-packages\pandas\core\generic.py", line 823, in _set_axis self._mgr.set_axis(axis, labels) File "C:\Users\duong\anaconda3\Lib\site-packages\pandas\core\internals\managers.py", line 230, in set_axis self._validate_set_axis(axis, new_labels) File "C:\Users\duong\anaconda3\Lib\site-packages\pandas\core\internals\base.py", line 70, in _validate_set_axis raise ValueError( ValueError: Length mismatch: Expected axis has 4 elements, new values have 12 elements".