Repository: spyder-ide/spyder

Issue:
"TypeError: 'bool' object is not callable" in dataframe viewer
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

#### creo que se debe a la version de spyder ya que lo acabo de actualizar.

### Traceback
```python-traceback
  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\dataframeeditor.py", line 576, in <lambda>
    slot = lambda func=func: self.change_type(func)
  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\dataframeeditor.py", line 588, in change_type
    [model.setData(i, '', change_type=func) for i in index_list]
  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\dataframeeditor.py", line 588, in <listcomp>
    [model.setData(i, '', change_type=func) for i in index_list]
  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\dataframeeditor.py", line 411, in setData
    self.df.iloc[row, column] = change_type(val)
TypeError: 'bool' object is not callable
```

## Versions

* Spyder version: 4.0.1 
* Python version: 3.7.6
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Windows 10

### Dependencies

```
atomicwrites >=1.2.0         :  1.3.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
cloudpickle >=0.5.0          :  1.3.0 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
intervaltree                 :  None (OK)
IPython >=4.0                :  7.12.0 (OK)
jedi =0.14.1                 :  0.14.1 (OK)
nbconvert >=4.0              :  5.6.1 (OK)
numpydoc >=0.6.0             :  0.9.2 (OK)
pexpect >=4.4.0              :  4.8.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
psutil >=0.3                 :  5.6.7 (OK)
pygments >=2.0               :  2.5.2 (OK)
pylint >=0.25                :  2.4.4 (OK)
pyls >=0.31.2;<0.32.0        :  0.31.7 (OK)
zmq >=17                     :  18.1.1 (OK)
qdarkstyle >=2.7             :  2.8 (OK)
qtawesome >=0.5.7            :  0.6.1 (OK)
qtconsole >=4.6.0            :  4.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
rtree >=0.8.3                :  0.9.3 (OK)
sphinx >=0.6.6               :  2.4.0 (OK)
spyder_kernels >=1.8.1;<2.0.0:  1.8.1 (OK)
watchdog                     :  None (OK)
cython >=0.21                :  0.29.15 (OK)
matplotlib >=2.0.0           :  3.1.3 (OK)
numpy >=1.7                  :  1.18.1 (OK)
pandas >=0.13.1              :  1.0.1 (OK)
scipy >=0.17.0               :  1.4.1 (OK)
sympy >=0.7.3                :  1.5.1 (OK)
```



Discussion:
Hola!! Gracias por reportar este error.

@dalthviz, please take a look at this one. It's certainly incorrect that we're trying to do `change_type(val)` when `change_type` is a bool. The problem is I don't understand when that can be the case.
Note: This happens when using the `To <something>` option of the DataFrameEditor.

Resolving patch:
diff --git a/spyder/plugins/variableexplorer/widgets/dataframeeditor.py b/spyder/plugins/variableexplorer/widgets/dataframeeditor.py
--- a/spyder/plugins/variableexplorer/widgets/dataframeeditor.py
+++ b/spyder/plugins/variableexplorer/widgets/dataframeeditor.py
@@ -583,7 +583,8 @@ def setup_menu(self):
                      (_("To str"), to_text_string))
         types_in_menu = [copy_action]
         for name, func in functions:
-            slot = lambda func=func: self.change_type(func)
+            def slot():
+                self.change_type(func)
             types_in_menu += [create_action(self, name,
                                             triggered=slot,
                                             context=Qt.WidgetShortcut)]


Test patch:
diff --git a/spyder/plugins/variableexplorer/widgets/tests/test_dataframeeditor.py b/spyder/plugins/variableexplorer/widgets/tests/test_dataframeeditor.py
--- a/spyder/plugins/variableexplorer/widgets/tests/test_dataframeeditor.py
+++ b/spyder/plugins/variableexplorer/widgets/tests/test_dataframeeditor.py
@@ -83,6 +83,31 @@ def generate_pandas_indexes():
 # =============================================================================
 # Tests
 # =============================================================================
+def test_dataframe_to_type(qtbot):
+    """Regression test for spyder-ide/spyder#12296"""
+    # Setup editor
+    d = {'col1': [1, 2], 'col2': [3, 4]}
+    df = DataFrame(data=d)
+    editor = DataFrameEditor()
+    assert editor.setup_and_check(df, 'Test DataFrame To action')
+    editor.show()
+    qtbot.waitForWindowShown(editor)
+
+    # Check editor doesn't have changes to save and select an initial element
+    assert not editor.btn_save_and_close.isEnabled()
+    view = editor.dataTable
+    view.setCurrentIndex(view.model().index(0, 0))
+
+    # Show context menu and select option `To bool`
+    view.menu.show()
+    qtbot.keyPress(view.menu, Qt.Key_Down)
+    qtbot.keyPress(view.menu, Qt.Key_Down)
+    qtbot.keyPress(view.menu, Qt.Key_Return)
+
+    # Check that changes where made from the editor
+    assert editor.btn_save_and_close.isEnabled()
+
+
 def test_dataframe_datetimeindex(qtbot):
     """Regression test for spyder-ide/spyder#11129 ."""
     ds = Series(