我有这段代码,它给了我想要的结果,但也显示了一个错误,这个错误意味着什么,以及如何修复它?
s_and = df_android['Category']
total_and = s_and.value_counts()
percentage_and = s_and.value_counts(normalize=True).mul(100).round(2)
percentage_tab_and = pd.DataFrame({'Total':total_and, 'Percentage':percentage_and}).reset_index()
percentage_tab_and = percentage_tab_and.rename(columns={"index": "Category"})
percentage_tab_and.head(5)结果:
| Category | Total | Percentage |
| ----------- | ----------- |------------|
| Dict | 3 | 36 |
| Book | 2 | 24 |错误:
ValueError Traceback (most recent call last)
~\anaconda3\lib\site-packages\pycodestyle_magic.py in auto_run_pycodestyle(self, result)
44
45 def auto_run_pycodestyle(self, result):
---> 46 pycodestyle(1, result.info.raw_cell, auto=True)
47 if result.error_before_exec:
48 print('Error before execution: %s' % result.error_before_exec)
<C:\Users\Sinch\anaconda3\lib\site-packages\decorator.py:decorator-gen-131> in pycodestyle(line, cell, auto)
~\anaconda3\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k)
218 # but it's overkill for just that one bit of state.
219 def magic_deco(arg):
--> 220 call = lambda f, *a, **k: f(*a, **k)
221
222 # Find get_ipython() in the caller's namespace
~\anaconda3\lib\site-packages\pycodestyle_magic.py in pycodestyle(line, cell, auto)
173 #logger.info(line)
174 # on windows drive path also contains :
--> 175 line, col, error = line.split(':')[-4:]
176 # do not subtract 1 for line for %%pycodestyle, inc pre py3.6 string
177 if auto:
ValueError: too many values to unpack (expected 3)发布于 2020-10-28 04:09:33
看起来这是一个关于冒号的pycodestyle_magic问题:https://github.com/mattijn/pycodestyle_magic/issues/20
作为解决此问题的一种方法,您可以禁用带有冒号的行的pycodestyle_magic:
%pycodestyle_off
percentage_tab_and = pd.DataFrame({'Total':total_and, 'Percentage':percentage_and}).reset_index()
percentage_tab_and = percentage_tab_and.rename(columns={"index": "Category"})
%pycodestyle_onhttps://stackoverflow.com/questions/61230004
复制相似问题