Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

df=qs.north_money('个股',5)报错无法执行 #36

Open
ZhongZhijun opened this issue Jul 8, 2024 · 1 comment
Open

df=qs.north_money('个股',5)报错无法执行 #36

ZhongZhijun opened this issue Jul 8, 2024 · 1 comment

Comments

@ZhongZhijun
Copy link

#北向资金增持个股情况
#有个小bug,列名没有对应起来,该函数调用将报错,将在新版本中修正。
df=qs.north_money('个股',5)
#df.tail()

报错无法执行:
1720425180230

@ZhongZhijun
Copy link
Author


ValueError Traceback (most recent call last)
Cell In[65], line 1
----> 1 df=qs.north_money('个股',5)

File c:\program files\python\lib\site-packages\qstock\data\money.py:142, in north_money(flag, n)
134 '''flag=None,默认返回北上资金总体每日净流入数据
135 flag='行业',代表北向资金增持行业板块排行
136 flag='概念',代表北向资金增持概念板块排行
(...)
139 即 {'1':"今日", '3':"3日",'5':"5日", '10':"10日",'M':"月", 'Q':"季", 'Y':"年"}
140 '''
141 if flag=='个股':
--> 142 return north_money_stock(n)
144 elif flag in ['行业','概念','地域']:
145 return north_money_sector(flag, n)

File c:\program files\python\lib\site-packages\qstock\data\money.py:232, in north_money_stock(n)
230 df.reset_index(inplace=True)
231 df["index"] = range(1, len(df) + 1)
--> 232 df.columns = [
233 "序号","","","日期","","名称","","","代码","", "","","",
234 "持股数","持股市值","持股占流通股比","持股占总股本比",
235 "收盘","涨幅","
","所属板块","","","","","","","", "",
236 "","", f'{period}增持市值',f'{period}增持股数',f'{period}增持市值增幅',
237 f'{period}增持占流通股比',f'{period}增持占总股本比',
238 "","","","","","","_",]
239 df = df[
240 ["代码","名称","收盘","涨幅", "持股数","持股市值","持股占流通股比",
241 "持股占总股本比",f'{period}增持股数',f'{period}增持市值',
242 f'{period}增持市值增幅',f'{period}增持占流通股比',f'{period}增持占总股本比',
243 "所属板块", "日期",] ]
244 df["日期"] = pd.to_datetime(df["日期"]).dt.date

File c:\program files\python\lib\site-packages\pandas\core\generic.py:5915, in NDFrame.setattr(self, name, value)
5913 try:
5914 object.getattribute(self, name)
-> 5915 return object.setattr(self, name, value)
5916 except AttributeError:
5917 pass

File c:\program files\python\lib\site-packages\pandas_libs\properties.pyx:69, in pandas._libs.properties.AxisProperty.set()

File c:\program files\python\lib\site-packages\pandas\core\generic.py:823, in NDFrame._set_axis(self, axis, labels)
821 def _set_axis(self, axis: int, labels: AnyArrayLike | list) -> None:
822 labels = ensure_index(labels)
--> 823 self._mgr.set_axis(axis, labels)
824 self._clear_item_cache()

File c:\program files\python\lib\site-packages\pandas\core\internals\managers.py:230, in BaseBlockManager.set_axis(self, axis, new_labels)
228 def set_axis(self, axis: int, new_labels: Index) -> None:
229 # Caller is responsible for ensuring we have an Index object.
--> 230 self._validate_set_axis(axis, new_labels)
231 self.axes[axis] = new_labels

File c:\program files\python\lib\site-packages\pandas\core\internals\base.py:70, in DataManager._validate_set_axis(self, axis, new_labels)
67 pass
69 elif new_len != old_len:
---> 70 raise ValueError(
71 f"Length mismatch: Expected axis has {old_len} elements, new "
72 f"values have {new_len} elements"
73 )

ValueError: Length mismatch: Expected axis has 44 elements, new values have 43 elements

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

No branches or pull requests

1 participant