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

Nan value in dataframe editor crash Spyder #4139

Closed
markusr opened this issue Feb 11, 2017 · 8 comments
Closed

Nan value in dataframe editor crash Spyder #4139

markusr opened this issue Feb 11, 2017 · 8 comments

Comments

@markusr
Copy link

markusr commented Feb 11, 2017

Description of your problem

  1. Run the following script:
import numpy as np
import pandas as pd

np_array = np.zeros(100)
np_array[10:] = np.nan
dataframe = pd.DataFrame(np_array)
  1. Go to the Variable explorer
  2. Double click on the dataframe variable
  3. Close the table editor window

What is the expected output? What do you see instead?
Spyder completely crashes. This is not always reproducible but opening and closing table editor several times triggers the crash.

Versions and main components

  • Spyder Version: 3.1.2
    Python 3.5.2 64bits
    Qt 5.7.0
    PyQt5 5.7
  • Operating system: Kubuntu 16.04

Dependencies

jedi >=0.8.1 : 0.10.0 (OK)
matplotlib >=1.0 : 1.5.3 (OK)
nbconvert >=4.0 : 5.1.1 (OK)
numpy >=1.7 : 1.12.0 (OK)
pandas >=0.13.1 : 0.18.1 (OK)
pep8 >=0.6 : 1.7.0 (OK)
psutil >=0.3 : 5.1.3 (OK)
pyflakes >=0.6.0 : 1.5.0 (OK)
pygments >=2.0 : 2.2.0 (OK)
pylint >=0.25 : 1.6.5 (OK)
qtconsole >=4.2.0: 4.2.1 (OK)
rope >=0.9.4 : 0.9.4-1 (OK)
sphinx >=0.6.6 : 1.5.2 (OK)
sympy >=0.7.3 : None (NOK)

@ccordoba12
Copy link
Member

ccordoba12 commented Feb 11, 2017

I can't reproduce this. How did you install Qt/PyQt?

@markusr
Copy link
Author

markusr commented Feb 12, 2017

I don't know how I installed it. All with standard packages and/or pip.

I did some further investigations:

  • The format (in variable explorer) has to be %d. Which I used before for a special dataframe.
  • There are exceptions in the internal console.
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/spyder/widgets/variableexplorer/dataframeeditor.py", line 277, in data
    return to_qvariant(self._format % value)
ValueError: cannot convert float NaN to integer

@ccordoba12
Copy link
Member

@jitseniesen, any ideas?

@jitseniesen
Copy link
Member

Yes, I understand it after markusr's explanation. The error message complains that the format %d is for integers and cannot be applied to NaN.

An easy solution for us would be to use the default format (which is %.3g) in this case. Would that be acceptable from a user experience point of view?

@markusr
Copy link
Author

markusr commented Feb 12, 2017

An easy solution for us would be to use the default format (which is %.3g) in this case. Would that be acceptable from a user experience point of view?

@jitseniesen Are you suggesting that non-NaN values are shown as %d and NaN values as %.3g (if %d is set as the input format)?

@jitseniesen
Copy link
Member

Yes

@markusr
Copy link
Author

markusr commented Feb 12, 2017

This sounds like a good solution. I also gave it some thoughts but I couldn't come up with better solution.

Anyhow better than the application crash...

@ccordoba12 ccordoba12 added this to the v3.1.4 milestone Feb 12, 2017
@ccordoba12 ccordoba12 changed the title [Variable explorer] Nan value in pandas dataframe crash spyder Nan value in dataframe editor crash Spyder Feb 12, 2017
@ccordoba12
Copy link
Member

@jitseniesen, could you create a PR against the 3.1.x branch for this? It seems an easy fix but I fail to understand what we should exactly do to fix it :-)

jitseniesen added a commit to jitseniesen/spyder that referenced this issue Feb 13, 2017
This handles the case where the data frame contains a NaN and the user
specifies the format '%d'. Fixes spyder-ide#4139.
jitseniesen added a commit to jitseniesen/spyder that referenced this issue Feb 13, 2017
jitseniesen added a commit to jitseniesen/spyder that referenced this issue Feb 13, 2017
This handles the case where the data frame contains a NaN and the user
specifies the format '%d'. Fixes spyder-ide#4139.
jitseniesen added a commit to jitseniesen/spyder that referenced this issue Feb 13, 2017
jitseniesen added a commit to jitseniesen/spyder that referenced this issue Feb 13, 2017
ccordoba12 added a commit that referenced this issue Feb 14, 2017
ccordoba12 added a commit that referenced this issue Feb 14, 2017
@ccordoba12 ccordoba12 modified the milestones: v3.1.3, v3.1.4 Feb 14, 2017
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

4 participants