spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.22k stars 1.59k forks source link

Cannot open the view [name] in Variable Explorer is not reponse. #16472

Open palitaHum opened 3 years ago

palitaHum commented 3 years ago

Description

What steps will reproduce the problem?

import numpy as np
import pandas as pd

aa = [1,2,3,4]

df = pd.DataFrame(
                  np.random.randint(1,10000,size=(4,2)),
                  columns=([aa],[]), #X
                  index=[aa]                 
                  )
a = pd.DataFrame(
            index= {'B' : ['Average','Max','Min','ArgMax','ArgMin']},
            columns= {'B' : ['Average','Max','Min','ArgMax','ArgMin']}
            )

df.append(a, ignore_index=True)

Traceback

  File "pandas/_libs/hashtable_class_helper.pxi", line 1709, in pandas._libs.hashtable.PyObjectHashTable.map_locations
TypeError: unhashable type: 'list'
Exception ignored in: 'pandas._libs.index.IndexEngine._call_map_locations'
Traceback (most recent call last):
  File "pandas/_libs/hashtable_class_helper.pxi", line 1709, in pandas._libs.hashtable.PyObjectHashTable.map_locations
TypeError: unhashable type: 'list'
Traceback (most recent call last):
  File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py", line 189, in createEditor
    if not editor.setup_and_check(value, title=key):
  File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/spyder/plugins/variableexplorer/widgets/dataframeeditor.py", line 946, in setup_and_check
    self.dataModel = DataFrameModel(data, parent=self)
  File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/spyder/plugins/variableexplorer/widgets/dataframeeditor.py", line 139, in __init__
    self.max_min_col_update()
  File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/spyder/plugins/variableexplorer/widgets/dataframeeditor.py", line 248, in max_min_col_update
    for dummy, col in self.df.iteritems():
  File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py", line 964, in iteritems
    yield from self.items()
  File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py", line 960, in items
    yield k, self._ixs(i, axis=1)
  File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py", line 2847, in _ixs
    result = self._box_col_values(values, i)
  File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py", line 3188, in _box_col_values
    return klass(values, index=self.index, name=name, fastpath=True)
  File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/pandas/core/series.py", line 332, in __init__
    self.name = name
  File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py", line 5161, in __setattr__
    object.__setattr__(self, name, value)
  File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/pandas/core/series.py", line 495, in name
    raise TypeError("Series.name must be a hashable type")
TypeError: Series.name must be a hashable type

Versions

Dependencies


# Mandatory:
applaunchservices >=0.1.7      :  0.2.1 (OK)
atomicwrites >=1.2.0           :  1.4.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.6.0 (OK)
diff_match_patch >=20181111    :  20200713 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.19.0 (OK)
jedi =0.17.1                   :  0.17.1 (OK)
nbconvert >=4.0                :  6.0.7 (OK)
numpydoc >=0.6.0               :  1.1.0 (OK)
parso =0.7.0                   :  0.7.0 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.2 (OK)
pygments >=2.0                 :  2.7.2 (OK)
pylint >=1.0                   :  2.6.0 (OK)
pyls >=0.34.0;<1.0.0           :  0.35.1 (OK)
qdarkstyle >=2.8               :  2.8.1 (OK)
qtawesome >=0.5.7              :  1.0.1 (OK)
qtconsole >=4.6.0              :  4.7.7 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.4 (OK)
sphinx >=0.6.6                 :  3.2.1 (OK)
spyder_kernels >=1.9.4;<1.10.0 :  1.9.4 (OK)
watchdog                       :  None (OK)
zmq >=17                       :  19.0.2 (OK)

# Optional:
cython >=0.21                  :  0.29.21 (OK)
matplotlib >=2.0.0             :  3.3.2 (OK)
numpy >=1.7                    :  1.19.2 (OK)
pandas >=0.13.1                :  1.1.3 (OK)
scipy >=0.17.0                 :  1.5.2 (OK)
sympy >=0.7.3                  :  1.6.2 (OK)
dalthviz commented 3 years ago

Hi @palitaHum I was able to reproduce this :+1: Although your dataframe definition (df variable) is invalid and running your code shows the traceback only when you interact with the dataframe (as for example when doing the append), the error you see when trying to open the dataframe from the variable explorer should be handled differently, so instead of the report error dialog showing up the dialog that says that was not possible to check the variable should be the one appearing (I think there is a dialog like that but not totally sure).

Pinging @ccordoba12 just in case

ccordoba12 commented 2 years ago

I agree with you @dalthviz, we need to handle this kind of error more gracefully.