Jupyter Lab issue regarding pandas and plotly initial import - python

Hey there I am relatively new to python. I have a hw assignment and it requires me to use an initial import of (import plotly.express as px). When I run the code it returns to me this (module 'pandas' has no attribute 'Panel'). I am using jupyter lab and I have been told that it has a lot of issues with plotly. I have also tried using jupyter notebook but still the same error. Some of my download versions include:
Python-dotenv : 0.16.0
Python : 3.7.9
Nb_conda : 2.2.1
Nodejs : 14.8.0
Npm : 6.14.7
Holoviz : 0.11.3
Plotly : 4.14.3
Pandas : 1.2.4
Please let me know if you have any solutions to this problem. Thanks

As the Pandas' documentation states, the Panel attribute has been deprecated since version 0.20.0. You are using a version of Pandas (1.2.4) which does not have this attribute anymore. In other words, your code is too old for the version of Pandas in Jupyter Lab.
To solve this, you should follow the documentation and update the code to use either an xarray or a MultiIndex as a replacement to Panel.
Alternatively, a quick and dirty to solve this specific issue is to install a downgraded version of Pandas, but you'll probably have to downgrade a lot of other packages too. So I cannot recommend this option. Anyway, you can do this by adding a cell with this command, before the import and then restarting your notebook environment:
!pip install pandas==0.19.2

I've been struggling with plotly.express and pandas in jupyter notebook as well.
I've recently upgraded pandas to 1.3.0 and plolty to 5.1.0.
I had the same error, make sure you upgrade all dependencies as well along with pandas and plotly.
For me this command in the console did the trick:
pip install xarray --upgrade

Related

import geopandas successfully, but raise issue with fiona(import error)

I am Windows and using python through jupyternotebook.
python 3.9.7, windows 64 bit,
I want to import geopandas, so I used the code conda install --channel conda-forge geopandas. It seemed work at first because I could successfully import geopandas without error, but when I want to run the following code, an import error appears.
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
world.columns
ImportError: the 'read_file' function requires the 'fiona' package, but it is not installed or does not import correctly.
Importing fiona resulted in: DLL load failed while importing ogrext
I saw other people asked the same questions, but none of their solutions worked. At first, I saw someone said nstalling geopandas by condas might installed wrong version of fiona and gdal. So I tried to update by conda update conda, and conda update -n base conda-package-handling and conda update --all. However, these code didn't work. Later, I directly installed the .whl file from python library: Fiona-1.8.20-cp39-cp39-win_amd64.whl and GDAL-3.4.1-cp39-cp39-win_amd64.whl, and use pip to install them. But the error still appeared.
I really have no idea how to deal with such issue, is it because the version of fiona and gdal was not consistent? Please give me some suggestions, thanks ahead!
I have solved this problem by creating a new environment followed this article: https://medium.com/analytics-vidhya/fastest-way-to-install-geopandas-in-jupyter-notebook-on-windows-8f734e11fa2b
This is the fast way to solve this problem.

Zipline installation trouble

After I installed zipline with the anaconda prompt everything was imported and installed correctly. But in the Jupyter notebook, I am getting error like no module called 'matplotlib' or pandas 'DataReader' is not working. When I try to install it in the notebook and restart the kernel, the zipline import is no longer working. How can I solve this? What is wrong with the zipline installation?
zipline has very specific dependencies like pandas 0.18.0 and pandas DataReader 0.8.0. So make sure you have the correct version of those. And by the way, I find the tutorial here very useful.
Hope it could help

Runtime warning when importing libraries in jupyter notebook

So, I have never had this issue before on prior laptops- but recently on my new laptop- I get runtime warnings when trying to import libraries into Jupyter notebook- I'm not sure of the cause or how to fix it. Any solutions?
enter image description here
Maybe there is some problem with the package which showing warning. Try to re-install the package.
First check whether the package working properly. If not install the pakage. Here in your screenshot it shows problem with numpy. To install numpy follow
pip install numpy
Or
python -m pip install numpy
If the packages are working but still warning persist, then put the below code to remove the warning.
import warnings
warnings.filterwarnings('ignore')
warnings.simplefilter('ignore')

Taylor diagram in python by using skill_metrics

I tried to use skill_metris to create taylor diagram. But I am getting error saying that
module 'matplotlib.colors' has no attribute 'to_rgb'
example code:
import skill_metrics as sm
sm.taylor_diagram(0.22,0.52,0.32)
Answer can be find on github project FAQ
https://github.com/PeterRochford/SkillMetrics/wiki/FAQ
From site:
A3. This problem occurs when using an earlier version of matplotlib
than 2.0.0. The latter is distributed with Python 3.6 but standard
distributions of Python 2.7 are usually distributed with earlier
versions of matplotlib (e.g. 1.3.1 and 1.5.0). To check what version
of matplotlib you are using execute the following statements at the
Python command line (or within a script):
import matplotlib
matplotlib.__version__
I order to get newer matplotlib version you can use following pip command. pip install -U matplotlib.
I managed to solve this issue by installing the following modules on google colab:
! pip install XlsxWriter
! pip install SkillMetrics

Importing mpl_toolkits.basemap on Windows?

I have recently started using Python 3.5 and Anaconda on my Windows pc. I am trying to plot a map. However, When I am in my Jupyter notebook and i type the command
import mpl_toolkits.basemap
I get an error message saying 'no module name' 'mpl_toolkits.basemap'
However, I have the module downloaded and in the same C:\Users\Geena file as my .matplotlib, .ipython, .jupyter files, etc.
Anyone know how I can fix this?
I've had this issue with anaconda on my windows 7.
I found the way to fix it with python 3.5:
You need to run with administrator rights "Anaconda Prompt" and in "Anaconda Prompt" run following command:
conda install -c conda-forge basemap-data-hires=1.0.8.dev0
, it will show new packages that you need to install and will ask you to install it - say 'Yes'.
After that new packages will be installed and the issue "import mpl_toolkits.basemap" will be fixed.
Thank you.
Currently, basemap is not compatible with python 3 for windows users. So, if you try conda install basemap and you have python 3 installed in windows, you'll see a message pointing out that a conflict was found with python 3.
I solved this by installing a python 2.7 environment. Try this:
http://conda.pydata.org/docs/py2or3.html
Then you just activate the python 2 environment. For example: activate py27 (py27 is the identifier of my python 2.7 environment).
After that, you can run conda install basemap with no conflict.
I'm using python 3.6.4 on Windows 7 Family Premium (32bit).
Because I was a bit frustrated by the message "no module named 'mpl_toolkits.basemap'", I searched for and tried a dozen of solutions without success : various versions, building from source, problems with VS version, nmake, ... You all know what I mean ;-)
I finally found a quite simple solution that works perfectly well for me :-) Here it is !
from here I downloaded basemap‑1.1.0‑cp36‑cp36m‑win32.whl
I changed the current dir to my download dir
I installed the wheel with python -m pip basemap‑1.1.0‑cp36‑cp36m‑win32.whl
I did the same for matplotlib‑2.2.3‑cp36‑cp36m‑win32.whl
You DO read the versions correctly : matplotlib 2.2.3 and basemap 1.1.0
Everything works fine for me and I finally can plot OSM POI's on a map of Belgium, without any 'trickery' at import :
import requests # to fetch OSM data
import json # to get the response
from mpl_toolkits.basemap import Basemap # ... Belgium is there !
import numpy as np # for arrays
import matplotlib.pyplot as plt # to build the populated map
Big big thanks to Christoph Gohlke (Danke Dir Christoph !) who did all the wonderful job !
When you have Anaconda, you don't download modules anywhere. In your command prompt, you type
conda install basemap
and it is installed with all its dependencies.
Anaconda requires an unusual install command for basemap 1.0.7.
https://anaconda.org/anaconda/basemap
To install this package with conda run:
conda install -c https://conda.anaconda.org/anaconda basemap
I just had this issue as well. All you need to do is update matplotlib by doing the following:
pip install --upgrade matplotlib
mpl_toolkits is part of matplotlib and just needs to be updated.
If you're using anaconda, the easiest thing to do is described here: in the conda prompt (as admin), type conda install -c anaconda basemap.
For people of the future : "Basemap is deprecated in favor of the Cartopy project."
https://matplotlib.org/basemap/users/intro.html#cartopy-new-management-and-eol-announcement

Categories