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

Pandas index type can't be viewed in variable viewer #21160

Open
mg3146 opened this issue Jul 19, 2023 · 16 comments
Open

Pandas index type can't be viewed in variable viewer #21160

mg3146 opened this issue Jul 19, 2023 · 16 comments

Comments

@mg3146
Copy link

mg3146 commented Jul 19, 2023

Hi, it seems that certain (Int64Index in this case) built-in pandas.Index don't work with the variable viewer.

image

I'm unsure if this is unique to Spyder 6 (Windows) or all versions (I'm using the standalone spyder 6 installer), and there could be other index types that dont work that I'm unaware of.

Here is a bit of reproducible code:

import pandas as pd
import datetime as dt

cols = pd.Index(range(5))
index = pd.Index(pd.bdate_range(dt.date.today(),periods=10))
data = {key : [i/1.25 for i in range(10)] for key in cols}

df = pd.DataFrame(data, index = index, columns = cols)
print(f'I work!:    {df.columns}')

df.columns = pd.Index([i for i in range(5)])

print(f'I dont work!:    {df.columns}')

(PS. Hopefully I dont make myself look silly by ignoring the very direct "dont report to github" message :) )

@ccordoba12
Copy link
Member

Hey @mg3146, thanks for reporting. What's the variable you tried to open in the Variable Explorer which gave you the error above? cols or index?

(PS. Hopefully I dont make myself look silly by ignoring the very direct "dont report to github" message :) )

Don't worry about it, that's fine.

@mg3146
Copy link
Author

mg3146 commented Jul 20, 2023

so in both cases I'm trying to open 'df' in the variable viewer. The difference between the 2 cases is what index type df has.

@ccordoba12
Copy link
Member

ccordoba12 commented Aug 8, 2023

I can't reproduce this on Linux.

@dalthviz, could you give me a hand reviewing this on Windows? Thanks!

@dalthviz
Copy link
Member

dalthviz commented Aug 8, 2023

Checked running the code provided from a temporary file on a Spyder 6.0.0a1 installation done with the Windows installer but seems like no issue is raised:

image

To run the code I used the default Python interpreter that comes with Spyder and used the default run configuration.

Installation details:

  • Spyder version: 6.0.0a1 0d7fb75 (standalone)
  • Python version: 3.9.16 64-bit
  • Qt version: 5.15.6
  • PyQt5 version: 5.15.7
  • Operating System: Windows-10-10.0.19045-SP0

Maybe there are other steps to follow in order to reproduce this @mg3146 ?

@mg3146
Copy link
Author

mg3146 commented Aug 8, 2023 via email

@ccordoba12
Copy link
Member

3.0b1.

@dalthviz
Copy link
Member

dalthviz commented Aug 9, 2023

Could it be that the error comes from using a custom interpreter?

@mg3146
Copy link
Author

mg3146 commented Aug 9, 2023

This seems to be working for me now - I must have had some conflict or something in my interpeter. Sorry for the windup!

@mg3146 mg3146 closed this as completed Aug 9, 2023
@mg3146 mg3146 reopened this Aug 9, 2023
@mg3146
Copy link
Author

mg3146 commented Aug 9, 2023

I should have finished my coffee before looking at this. Indeed its still not working - and yup, I'm using a custom interpreter. Let me know if you want me to post all the packages in it - but a few of the ones below. Spyder is installed with the standalone installer.
image

spyder-kernels            3.0.0b1                  pypi_0    pypi
ipykernel                 6.19.2           py39hd4e2768_0
ipynb-py-convert          0.4.6              pyh9f0ad1d_0    conda-forge
ipython                   8.14.0                   pypi_0    pypi
ipython_genutils          0.2.0              pyhd3eb1b0_1
ipywidgets                8.0.4            py39haa95532_0
pandas                    1.5.3            py39hf11a4ad_0

@dalthviz
Copy link
Member

dalthviz commented Aug 9, 2023

Not totally sure but maybe a mismatch between the installer pandas version and the one you have installed in your custom interpreter env could be causing the dialog to appear. I think the installers come with pandas 2.0.3 and seems like the pandas version related with your custom environment has pandas 1.5.3. Could it be possible for you to update the pandas version in your custom Python interpreter env from 1.5.3 to 2.0.3?

@mg3146
Copy link
Author

mg3146 commented Aug 9, 2023 via email

@ccordoba12
Copy link
Member

@dalthviz, could you check this with Pandas 1.5.3? Maybe the problem is that serialization of Dataframes between Pandas 2 and 1.5 is incompatible (we've seen that before a couple of times), so we need to account for that somehow.

@dalthviz
Copy link
Member

dalthviz commented Aug 9, 2023

I was able to reproduce this when using a custom interpreter which has pandas 1.5.3 while using Spyder 6.0.0a1 from the Windows installer:

image

Seems like the error indeed comes from the serialization. Running Spyder in debug mode I see the following message:

2023-08-09 18:42:41,770 [DEBUG] [spyder_kernels.comms.commbase] -> Exception in cloudpickle.loads : No module named 'pandas.core.indexes.numeric'

@mg3146
Copy link
Author

mg3146 commented Aug 10, 2023

anything else needed from me at this point?

@ccordoba12
Copy link
Member

You need to either update Pandas to its 2.0 version in your environment or create a new environment with Spyder 6a1 and Pandas 1.5 and then connect it to your custom env.

@Ax-sudo
Copy link

Ax-sudo commented Aug 28, 2023

Hi there,
jumping on board of this thread with a question. I had the same problem while running Pandas 2.03 in a custom env, while Pandas 1.5 was installed in base environment. Updating that in base environment solved the problem for me in the custom one. Why would updating packages in the base environment affect the custom one?

Python 3.11.4
Spyder 5.4.3
Windows 10
Anaconda

@ccordoba12 ccordoba12 modified the milestones: v5.5.0, v6.0.1 Oct 20, 2023
@ccordoba12 ccordoba12 changed the title Spyder 6: Pandas index type can't be viewed in variable viewer Pandas index type can't be viewed in variable viewer Oct 31, 2023
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