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

DataFrame Editor raises TypeError when editing any complex type #6115

Closed
CAM-Gerlach opened this issue Jan 3, 2018 · 1 comment
Closed

Comments

@CAM-Gerlach
Copy link
Member

Description

When editing a column of a complex type (complex64, complex128 and the built in complex), the DataFrame Editor raises a TypeError when attempting to confirm/commit any edits to any of the values in the column. This seems to occur regardless of what value is entered, whether the original (displayed as “###j), a tuple, a single integer, etc. However, it works just fine for arrays, so perhaps that logic can just be ported over?

What steps will reproduce the problem?

  1. Create a DataFrame with at least one column being of a complex type. E.g.
import pandas as pd
import numpy as np
df = pd.DataFrame([0, 0, 0], dtype=np.complex128)
  1. Open the DataFrame in the Data Frame editor
  2. Doubleclick one of the complex values to edit and click away again to commit

What is the expected output? What do you see instead?

Expected: Either a functioning ability to input a complex value as works perfectly well for arrays, or at the very least a "The type of the cell is not a supported type" warning or just setting the cell to read only.

Instead, an error dialog with :

File "C:\Users\christopher.gerlach\Anaconda3\lib\site-packages\spyder\widgets\variableexplorer\dataframeeditor.py", line 368, in setData
self.df.iloc[row, column-1] = current_value.__class__(val)
TypeError: must be real number, not str

Proposed solution

Port whatever logic is currently used for ArrayEditor to handle working with complex types over to the DataFrame Editor, if that's practicable. If not, and there's no other straightforward way to fix this, just catch the exception and pop up a "The type of the cell is not a supported type" warning dialog on attempting to edit instead for the time being, or disable editing completely if possible (so a double click action is just ignored).

Version and main components

  • Spyder Version: 3.2.5
  • Python Version: 3.6.3
  • Qt Versions: 5.6.2, PyQt5 5.6 on Windows

Dependencies

pyflakes >=0.6.0 :  1.6.0 (OK)
pycodestyle >=2.3:  2.3.1 (OK)
pygments >=2.0   :  2.2.0 (OK)
pandas >=0.13.1  :  0.21.1 (OK)
numpy >=1.7      :  1.13.3 (OK)
sphinx >=0.6.6   :  1.6.3 (OK)
rope >=0.9.4     :  0.10.5 (OK)
jedi >=0.9.0     :  0.10.2 (OK)
nbconvert >=4.0  :  5.3.1 (OK)
sympy >=0.7.3    :  1.1.1 (OK)
cython >=0.21    :  0.26.1 (OK)
qtconsole >=4.2.0:  4.3.1 (OK)
IPython >=4.0    :  6.1.0 (OK)
pylint >=0.25    :  1.7.4 (OK)

@ccordoba12
Copy link
Member

Agreed with the proposed solution. I think someone fixed this for arrays a while ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants