Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use scipy.stats

I get an errr when using scipy.stats. in a script after importing scipy.

AttributeError: 'module' object has no attribute 'stats' 

Within script editor I can click on stats after typing scipy. from the pulldown menu, within python console I can not select python.stats from the pulldown menu, it's not there. I'm using pandas 2.7 and SciPy 0.13.0 Why is that? Any known issues?

like image 718
user3276418 Avatar asked Feb 28 '14 23:02

user3276418


People also ask

How do I import stats from Scipy?

In the above program, first, we need to import the norm module from the scipy. stats, then we passed the data as Numpy array in the cdf() function. To get the median of the distribution, we can use the Percent Point Function (PPF), this is the inverse of the CDF.

What is stats ttest_ 1samp?

This is a test for the null hypothesis that the expected value (mean) of a sample of independent observations a is equal to the given population mean, popmean.

How do I import a Scipy library?

Install SciPy using the pip command Python consists of pip command which is an official package installer. It is a package manager, we can install, delete, or update any package. We need to install pip for using the pip command. Once the requirement is satisfied we can use the pip command in terminal.

How do I know what version of Scipy I have?

To check which version of scipy is installed, use pip show scipy or pip3 show scipy in your CMD/Powershell (Windows), or terminal (macOS/Linux/Ubuntu) to obtain the output major.


1 Answers

expanding on my comment (to have a listed answer).

Scipy, as many other large packages, doesn't import all modules automatically. If we want to use the subpackages of scipy, then we need to import them directly.

However, some scipy subpackages load other scipy subpackages, so for example importing scipy.stats also imports a large number of the other packages. But I never rely on this to have the subpackage available in the namespace.

In many packages that use scipy, the preferred pattern is to import the subpackages to have them available by their names, for example:

>>> from scipy import stats, optimize, interpolate   >>> import scipy >>> scipy.stats Traceback (most recent call last):   File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'stats' >>> scipy.optimize Traceback (most recent call last):   File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'optimize'  >>> import scipy.stats >>> scipy.optimize <module 'scipy.optimize' from 'C:\Python26\lib\site-packages\scipy\optimize\__init__.pyc'> 
like image 174
Josef Avatar answered Sep 20 '22 05:09

Josef