Skip to content

Conversation

@Zerohertz
Copy link
Contributor

수정 전

>>> fdr.StockListing("KRX-DESC")
2025-09-05 21:34:43.397 | ERROR    | FinanceDataReader.krx.listing:read:85 - Unknown format code 'd' for object of type 'str'
Traceback (most recent call last):

  File "<stdin>", line 1, in <module>
  File "/opt/venv/main/lib/python3.12/site-packages/FinanceDataReader/data.py", line 160, in StockListing
    return KrxStockListing(market).read()
           │               └ 'KRX-DESC'<class 'FinanceDataReader.krx.listing.KrxStockListing'>
> File "/opt/venv/main/lib/python3.12/site-packages/FinanceDataReader/krx/listing.py", line 82, in read
    df_listing['Code'] = df_listing['Code'].apply(lambda x: '{:06d}'.format(x))
    │                    └            Name    Code               Sector                                           Industry ListingDate SettleMonth    Re...
    └            Name    Code               Sector                                           Industry ListingDate SettleMonth    Re...
  File "/opt/venv/main/lib/python3.12/site-packages/pandas/core/series.py", line 4935, in apply
    ).apply()
  File "/opt/venv/main/lib/python3.12/site-packages/pandas/core/apply.py", line 1422, in apply
    return self.apply_standard()
           │    └ <function SeriesApply.apply_standard at 0x1057e0fe0><pandas.core.apply.SeriesApply object at 0x10b78f380>
  File "/opt/venv/main/lib/python3.12/site-packages/pandas/core/apply.py", line 1502, in apply_standard
    mapped = obj._map_values(
             │   └ <function IndexOpsMixin._map_values at 0x105507b00>0       318060
               1       397810
               2       0044K0
               3       0010V0
               4       125490
                        ...  
               2762    000100
               2763    000120
               2764 ...
  File "/opt/venv/main/lib/python3.12/site-packages/pandas/core/base.py", line 925, in _map_values
    return algorithms.map_array(arr, mapper, na_action=na_action, convert=convert)
           │          │         │    │                 │                  └ True
           │          │         │    │                 └ None
           │          │         │    └ <function KrxStockListing.read.<locals>.<lambda> at 0x10bda2ca0>
           │          │         └ array(['318060', '397810', '0044K0', ..., '000050', '000700', '003480'],
           │          │                 shape=(2767,), dtype=object)
           │          └ <function map_array at 0x10512aac0><module 'pandas.core.algorithms' from '/opt/venv/main/lib/python3.12/site-packages/pandas/core/algorithms.py'>
  File "/opt/venv/main/lib/python3.12/site-packages/pandas/core/algorithms.py", line 1743, in map_array
    return lib.map_infer(values, mapper, convert=convert)
           │   │         │       │               └ True
           │   │         │       └ <function KrxStockListing.read.<locals>.<lambda> at 0x10bda2ca0>
           │   │         └ array(['318060', '397810', '0044K0', ..., '000050', '000700', '003480'],
           │   │                 shape=(2767,), dtype=object)
           │   └ <cyfunction map_infer at 0x104cf6500><module 'pandas._libs.lib' from '/opt/venv/main/lib/python3.12/site-packages/pandas/_libs/lib.cpython-312-darwin.so'>
  File "pandas/_libs/lib.pyx", line 2999, in pandas._libs.lib.map_infer
  File "/opt/venv/main/lib/python3.12/site-packages/FinanceDataReader/krx/listing.py", line 82, in <lambda>
    df_listing['Code'] = df_listing['Code'].apply(lambda x: '{:06d}'.format(x))
                                                         │                  └ '318060''318060'

ValueError: Unknown format code 'd' for object of type 'str'
        Code    Name  Market                                 Sector                        Industry ListingDate SettleMonth     Representative                       HomePage Region
0     060310      3S  KOSDAQ  측정, 시험, 항해, 제어  기타 정밀기기 제조업; 광학기기 제외                     반도체 웨이퍼 캐리어  2002-04-23         03                정완영           http://www.3sref.com  서울특별시
1     095570  AJ네트웍스   KOSPI                        산업용 기계  장비 임대업             렌탈(파렛트, OA장비, 건설장비)  2015-08-21         12                곽정호         http://www.ajnet.co.kr  서울특별시
2     006840   AK홀딩스   KOSPI                                 기타 금융업                            지주사업  1999-08-11         12  고준, 채형석 (각자 대표이사)  http://www.aekyunggroup.co.kr  서울특별시
3     054620     APS  KOSDAQ                                 기타 금융업                     인터넷 트래픽 솔루션  2001-12-04         12                정기로   http://www.apsholdings.co.kr    경기도
4     265520   AP시스템  KOSDAQ                          특수 목적용 기계 제조업                     디스플레이 제조 장비  2017-04-07         12         Yoo Ho Sun     http://www.apsystems.co.kr    경기도
...      ...     ...     ...                                    ...                             ...         ...         ...                ...                            ...    ...
2876  000540    흥국화재   KOSPI                                    보험업                            손해보험  1974-12-05         12                송윤상     http://www.insurance.co.kr  서울특별시
2877  000545   흥국화재우   KOSPI                                    NaN                             NaN         NaT         NaN                NaN                            NaN    NaN
2878  003280    흥아해운   KOSPI                                 해상 운송업                  외항화물운송업(케미컬탱커)  1976-06-29         12                이환구         http://www.heung-a.com  서울특별시
2879  037440      희림  KOSDAQ               건축기술, 엔지니어링  관련 기술 서비스업                       설계  감리용역  2000-02-03         12    정영균, 권기재 (각자대표)          http://www.heerim.com  서울특별시
2880  238490      힘스  KOSDAQ                          특수 목적용 기계 제조업  OLED Mask 인장기, OLED Mask 검사기   2017-07-20         12                김주환          http://www.hims.co.kr  인천광역시

[2881 rows x 10 columns]

수정 후

>>> fdr.StockListing("KRX-DESC")
        Code    Name  Market                                 Sector                        Industry ListingDate SettleMonth     Representative                       HomePage Region
0     060310      3S  KOSDAQ  측정, 시험, 항해, 제어  기타 정밀기기 제조업; 광학기기 제외                     반도체 웨이퍼 캐리어  2002-04-23         03                정완영           http://www.3sref.com  서울특별시
1     095570  AJ네트웍스   KOSPI                        산업용 기계  장비 임대업             렌탈(파렛트, OA장비, 건설장비)  2015-08-21         12                곽정호         http://www.ajnet.co.kr  서울특별시
2     006840   AK홀딩스   KOSPI                                 기타 금융업                            지주사업  1999-08-11         12  고준, 채형석 (각자 대표이사)  http://www.aekyunggroup.co.kr  서울특별시
3     054620     APS  KOSDAQ                                 기타 금융업                     인터넷 트래픽 솔루션  2001-12-04         12                정기로   http://www.apsholdings.co.kr    경기도
4     265520   AP시스템  KOSDAQ                          특수 목적용 기계 제조업                     디스플레이 제조 장비  2017-04-07         12         Yoo Ho Sun     http://www.apsystems.co.kr    경기도
...      ...     ...     ...                                    ...                             ...         ...         ...                ...                            ...    ...
2876  000540    흥국화재   KOSPI                                    보험업                            손해보험  1974-12-05         12                송윤상     http://www.insurance.co.kr  서울특별시
2877  000545   흥국화재우   KOSPI                                    NaN                             NaN         NaT         NaN                NaN                            NaN    NaN
2878  003280    흥아해운   KOSPI                                 해상 운송업                  외항화물운송업(케미컬탱커)  1976-06-29         12                이환구         http://www.heung-a.com  서울특별시
2879  037440      희림  KOSDAQ               건축기술, 엔지니어링  관련 기술 서비스업                       설계  감리용역  2000-02-03         12    정영균, 권기재 (각자대표)          http://www.heerim.com  서울특별시
2880  238490      힘스  KOSDAQ                          특수 목적용 기계 제조업  OLED Mask 인장기, OLED Mask 검사기   2017-07-20         12                김주환          http://www.hims.co.kr  인천광역시

[2881 rows x 10 columns]

Signed-off-by: Zerohertz <ohg3417@gmail.com>
@FinanceData FinanceData merged commit efd841d into FinanceData:master Dec 21, 2025
@FinanceData
Copy link
Owner

PR 감사합니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants