INVESTAR / StockAnalysisInPython

457 stars 412 forks source link

5장 오류 질문입니다 #140

Open cheesss opened 2 years ago

cheesss commented 2 years ago

올려주신 네이버 웹스크롤 가능한 코드로 했는데 이런식으로 뜹니다. 혹시 조언해주실 수 있나요?

Traceback (most recent call last): File "C:\Users\chohjender\anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 3361, in get_loc return self._engine.get_loc(casted_key) File "pandas_libs\index.pyx", line 76, in pandas._libs.index.IndexEngine.get_loc File "pandas_libs\index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc File "pandas_libs\hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas_libs\hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'code'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "c:\myPackage\cho_DBUpdater.py", line 161, in dbu = DBUpdater() File "c:\myPackage\cho_DBUpdater.py", line 41, in init self.update_comp_info() File "c:\myPackage\cho_DBUpdater.py", line 57, in update_comp_info self.codes[df['code'].values[idx]]=df['company'].values[idx] #�о�� ���̺��� �̿��� codes ��ųʸ��� �����. File "C:\Users\chohjender\anaconda3\lib\site-packages\pandas\core\frame.py", line 3458, in getitem indexer = self.columns.get_loc(key) File "C:\Users\chohjender\anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 3363, in get_loc raise KeyError(key) from err KeyError: 'code'

INVESTAR commented 2 years ago

HediSQL로 mariaDB에 접속하셔서 아래 사항을 확인해 보시기 바랍니다.

  1. company_info 테이블의 code 컬럼명이 소문자 code가 맞는지
  2. investar 데이터베이스의 인코딩 방식이 utf8_general_ci로 설정되어 있는지
CREATE TABLE IF NOT EXISTS company_info (
code VARCHAR(20),
company VARCHAR(40),
last_update DATE,
PRIMARY KEY (code)
);