why mode in scipy.stats do not work

996 views Asked by At

i want to get mode of a list, so i try to use mode function in scipy, but i get the following error,

from scipy import stats

a = np.array([[6, 8, 3, 0],
...               [3, 2, 1, 7],
...               [8, 1, 8, 4],
...               [5, 3, 0, 5],
...               [4, 7, 5, 9]])

mode(a)

error message:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-9-4f9bea4011df> in <module>()
----> 1 from scipy import stats
      2 
      3 a = np.array([[6, 8, 3, 0],
      4 ...               [3, 2, 1, 7],
      5 ...               [8, 1, 8, 4],

c:\python34\lib\site-packages\scipy\stats\__init__.py in <module>()
    319 from __future__ import division, print_function, absolute_import
    320 
--> 321 from .stats import *
    322 from .distributions import *
    323 from .morestats import *

c:\python34\lib\site-packages\scipy\stats\stats.py in <module>()
    178 from scipy._lib.six import callable, string_types
    179 from numpy import array, asarray, ma, zeros
--> 180 import scipy.special as special
    181 import scipy.linalg as linalg
    182 import numpy as np

c:\python34\lib\site-packages\scipy\special\__init__.py in <module>()
    599 from __future__ import division, print_function, absolute_import
    600 
--> 601 from ._ufuncs import *
    602 
    603 from .basic import *

ImportError: DLL load failed: can not find module.

what's the problem here ? although i can import statistics, and use mode function of that, i also want to make it clear why scipy.stats can not be used ? is there some changes in python 3.4 for that moudle ?

1

There are 1 answers

1
apatniv On

It looks like you are running this code under windows. How did you install the scipy package. If you are just trying out the scipy package under windows, it is much easier to work with anaconda installation. (https://docs.continuum.io/)

List of packages (includes scipy too): (https://docs.continuum.io/anaconda/pkg-docs)

The package manager comes with all the modules (along with necessary libraries included) and works for all the platforms and it is a breeze to make it work on windows.

I personally encountered lot of issues while installing numpy, scipy, pandas on windows, therefore i switched to Anaconda.