How do I fix: ImportError: cannot import name 'PandaRequest'? - python

This is my first time using a jupyter notebook.
I was trying to import the panda module:
import panda as pd
but I get the following error:
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/panda/__init__.py in <module>()
----> 1 from request import PandaRequest
ImportError: cannot import name 'PandaRequest'
How to fix this?
Edit: I wanted to use pandas but typed panda instead. :'D

You have installed and imported the panda module, which is the a Python implementation of the Panda REST interface and which has incomplete dependencies.
What you probably want to do is install pandas (with the final s) and import that.

I got the same problem and come up with the following solutions:
import pandas as pd
instead of
import panda as pd
It is called pandas.

Execute pip install panda. You don't have the Panda module.
Edit: My mistake, it looks like there's an error within the Panda module itself. Does it rely on PandaRequest?

Related

No module named 'netCDF4'

I am currently working with netCDF data in the Spyder IDE, however when I try to import 'Dataset' from the module
from netCDF4 import Dataset
it is giving me the following error: "No module named 'netCDF4'". I already installed the module but I guess it is not in the same environment where I installed spyder. How can I fix this? If it helps solving my question. When I try to install netCDF4 in the spyder console using 'pip install netCDF4' it gives the following error:
"/Applications/Spyder.app/Contents/MacOS/python: No module named pip
Note: you may need to restart the kernel to use updated packages."
I looked up the path of the module: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/netCDF4'
and I guess the path for spyder is:
'/Applications/Spyder.app/Contents/MacOS/python'
How can I make sure that they are both located in the same environment?
I tried to look up the issue, however nothing really solved my problem.
Would be glad if anyone could help me out.
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from netCDF4 import Dataset
from cftime import numb2date
import tifffile as tifffile
# define arrays
XNR=[] # number
Xdt=[] # time
YGP=[] # GPP
YPP=[] # PPFD
# read csv file and extract column 0 (timestemp), PPFD (column 54) and GPP (column 312)
# take a file from FLUXNET for validation of the GPP model
with open(r'/Users/janoschbeer/Documents/Studium/ESS/ES_Observ/Assignments/Lab6/FLX_SJ-Adv_FLUXNET2015_SUBSET_2011-2014_1-4/FLX_SJ-Adv_FLUXNET2015_SUBSET_DD_2011-2014_1-4.csv') as csv:
lines = csv.readlines()
for i in range(2, len(lines)):
tmp=lines[i].split(",")
XNR.append(float(i))
Xdt.append(float(tmp[0]))
YGP.append(float(tmp[312]))
YPP.append(float(tmp[54]))

Easy install python modules for Jupyter notebooks?

Lately I've been learning a bit about Python. Jupyter notebooks seem like a good idea in theory, in practice I'm having some difficulty setting up the python modules within a Jupyter environment.
For example, I found this neat geographical data article and I want to follow along. There is a very nice github project that I downloaded to follow along.
Start up Jupyter and everything looks in order until I run the first code block:
import pandas as pd
import re
from datetime import datetime
from dateutil.parser import parse
import missingno as msno
import numpy as np
import seaborn as sb
import matplotlib.pyplot as plt
import json
This immediately generates an error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-422e89229f53> in <module>
----> 1 import pandas as pd
2 import re
3 from datetime import datetime
4 from dateutil.parser import parse
5 import missingno as msno
ModuleNotFoundError: No module named 'pandas'
There are quite a few modules and I guess I can go into the command line to add them each individually. That doesn't seem efficient. Is there some other 'Jupyter' or 'Conda' way to do this?
Within Jupyter notebooks you can execute command line methods using ! at the start of the line e.g.
! conda install pandas --yes
More detail on the inner working is discussed in this question:
Running interactive command line code from Jupyter notebook
Thanks to #PaulH for pointing out the need to add the --yes flag.
just run this in Jupyter:
!pip install <the name of the module>, <the name of the module>, <the name of the module>...
this will install the module you choose.
For example :
!pip install pandas, re, ...

Dask - import dask_ml.cluster - ModuleNotFoundError: No module named 'sklearn.cluster._k_means'

I would like to use Dask to create a simple clustering model. I have tried the following import statements individually (in separate cells) in Jupyter Notebooks:
import dask_ml.cluster
from dask_ml.cluster import KMeans
from dask_ml.cluster import SpectralClustering
Each of them separately resulting in the following error:
ModuleNotFoundError: No module named 'sklearn.cluster._k_means'
This seems really strange. Has anyone experienced this?
I encourage you to update Dask-ML to the latest release

NameError: name 'HTMLSession' is not defined when calling yahoo_fin.options.get_expiration_dates()

I'm calling yahoo_fin.options.get_expiration_dates() from a very simple code, such that it's unlikely that I have loaded other modules with the same name.
My whole code is this:
import matplotlib.pyplot as plt
import pandas as pd
from numpy import *
from yahoo_fin import options
plt.style.use("seaborn")
expirationDates = options.get_expiration_dates("goog")
The output of the last line is:
NameError: name 'HTMLSession' is not defined
Can you help me understand what's going on?
yahoo_fin requires requests-html for a few of its functions, including the yahoo_fin.options.get_expiration_dates method. You can install it using pip (it requires Python 3.6+):
pip install requests-html
Once installed, you need to restart your Python session. This link provides information on what functionality requires requests-html.

ImportError: cannot import name DataFrame

I am using Pandas for the first time and trying to import Pandas, DataFrame and pandas.io.data as such
import pandas as pd
from pandas import DataFrame
import pandas.io.data
I get the error
"ImportError: cannot import name DataFrame"
and
"ImportError: No module named io.data"
I have tried the following to find the source of error on Ubuntu 14.04:
$pip show pandas
-> Version: 0.14.0
Location: /home/new-pc/anaconda/lib/python2.7/site-packages
$$PATH
-> bash: /home/new-pc/anaconda/bin
Not sure where else to look for errors. Thanks for all the inputs.
You must be mixing Python installations, with several python programs/distributions (Anaconda), and maybe python version (2 and 3)
The following commands should not produce any error:
sudo apt-get install python
sudo pip install pandas
python -c'import pandas as pd; from pandas import DataFrame; import pandas.io.data'
It will happen if you call your file pandas.py and try to run it. You should rename the file then.
It will also occur if you save a pandas.py file in the Python directory. Check if you have any files called pandas.py there and rename/move those files to another location.
Try:
from pandas_datareader import data
as shown in the example here
Check if you have saved any file with same names as in pandas libraries, such as saving file name as DataFrame.py. Always avoid naming the program as same as library name check all the location.Once you remove/rename your python script will run without any issue.

Categories

Resources