Reputation: 875
I updated Pandas
package to 1.4.0
with cmd
, before that everything was working perfectly, but after doing so, my Spyder
environment threw the following error when trying to display a simple df
:
The code I ran was:
import pandas as pd
#column names
column_names = ["Time", "Currency", "Volatility expected", "Event", "Actual", "Forecast", "Previous"]
#create a dataframe including the column names
df = pd.DataFrame(columns=column_names)
It's important to mention that if I type df
in the spyder console, I DO get the information stored in the df
variable:
My only problem is that I can't see the details of that df when I click it in the Variable Explorer
Upvotes: 6
Views: 9227
Reputation: 613
This problem has plagued me for such a long time, but it persists after Pandas 1.4.0 if you are using Spyder in a virtual environment, as recommended by the Spyder docs. I found a simple solution.
Here is my basic environment:
**Spyder Environment**
Spyder, version 5.4.5
Python, version 3.10.4
**Working Environment**
Spyder-Kernels, version 2.4.4
Python, version 3.11.7
Pandas, version 2.1.4
If you read through the github issues thread link below, you will learn that when you call an variable through the variable explorer, that variable type must be supported by the environment that Spyder is installed in. So, this means if you are having trouble opening up a dataframe in Spyder, then it is likely that Pandas wasn't installed in your Spyder environment.
Run conda install pandas
in your Spyder environment, then restart Spyder. You are finished! Of course, if your having trouble with a different data type, then you need to install the correct package for that class.
GitHub thread here: https://github.com/spyder-ide/spyder/issues/15998
Upvotes: 4
Reputation: 21
I ran into this issue recently, and found that if I reset the index of the dataframe, I can then view the dataframe in the variable explorer. I did not have this issue in Spyder 4.
df.reset_index(inplace=True)
Edit:
Upon further investigation, it seems that Spyder 5 was built to work with pandas 2, and that's why there's so much weirdness around viewing some dataframes and why I did not see this issue in Spyder 4. A more helpful error message could definitely be used for these instances, like mentioning how it could be an issue of having deprecated packages. Oh well.
Upvotes: 2
Reputation: 40
In my case i have installed spyder in system-wide and i was working with spyder in a venv that is not true!
I insatalled spyder kernel in that venv by pip install spyder-kernels
and then ran the spyder by spyder
in terminal.
This was solved very simply for me :)
Upvotes: -1
Reputation: 875
It seems that my issue will be solved at the end of this month.
So, I had to downgrade my Pandas package to 1.3.5
version using pip install -Iv --user pandas==1.3.5
on cmd
, and conda install pandas==1.3.5
on my miniconda3
environment.
After that, my variable explorer ran smoothly:
Upvotes: 1