Micro-sheep / Micro-sheep/efinance

ef.stock.get_base_info()获取多只股票信息报错。

Open
#67 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.1k
Forks
755
PR merge metrics
No merged PRs in 30d

Description

stock_code = ['000001','159949']

df = ef.stock.get_base_info(stock_code)
print(df)

运行后报错如下:

Processing => 159949: 100%|██████████| 2/2 [00:00<00:00, 14.22it/s]Traceback (most recent call last):
  File "C:\Users\hdadmin\PycharmProjects\study\data\stock.py", line 58, in <module>
    df = ef.stock.get_base_info(stock_code)
  File "C:\Users\hdadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\efinance\utils\__init__.py", line 37, in run
    values = func(*args, **kwargs)
  File "C:\Users\hdadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\efinance\stock\getter.py", line 142, in get_base_info
    return get_base_info_muliti(stock_codes)
  File "C:\Users\hdadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\efinance\stock\getter.py", line 88, in get_base_info_muliti
    df = df.dropna(subset=['股票代码'])
  File "C:\Users\hdadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\util\_decorators.py", line 311, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\hdadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\frame.py", line 6002, in dropna
    raise KeyError(np.array(subset)[check].tolist())
KeyError: ['股票代码']
Processing => 159949: 100%|██████████| 2/2 [00:00<00:00, 11.64it/s]

Mac和win环境都测试,报错一样,获取单个股票信息没问题。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at efinance/stock/getter.py, especially get_base_info and get_base_info_muliti, then reproduce the reported call with ['000001', '159949']. The fix is complete when retrieving multiple stocks no longer raises KeyError for 股票代码 and still returns the expected dataframe, while single-stock retrieval continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.