pycodestyle_magic icon indicating copy to clipboard operation
pycodestyle_magic copied to clipboard

Error: Too many values to unpack

Open linhhlp opened this issue 2 years ago • 0 comments

Hi everyone,

I encountered this issue and didn't know why it was an error

Importing Pandas, Create DF

import pandas as pd
df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})

It works well until I want to validate/filter based on some conditions, and pycodestyle_magic stops

df2 = df.loc[
    (df.col1 == True), ["col1", "col2"]
]

This code should work without problems. The formatting was created by black on .py file and copy to Jupyter notebook.

Error content:

ValueError                                Traceback (most recent call last)
File [c:\Users\kim_l\anaconda3\envs\machinelearning\lib\site-packages\pycodestyle_magic.py:46](file:///C:/Users/kim_l/anaconda3/envs/machinelearning/lib/site-packages/pycodestyle_magic.py:46), in VarWatcher.auto_run_pycodestyle(self, result)
     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)

File [c:\Users\kim_l\anaconda3\envs\machinelearning\lib\site-packages\pycodestyle_magic.py:175](file:///C:/Users/kim_l/anaconda3/envs/machinelearning/lib/site-packages/pycodestyle_magic.py:175), in pycodestyle(line, cell, auto)
    170 stdout = sys.stdout.getvalue().splitlines()   
    172 for line in stdout:
    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)

linhhlp avatar Mar 31 '23 04:03 linhhlp