I just installed ANACONDA and have set up my virtual environment and profile. When I enter a command like
from pandas import *
or
from numpy import random
the system pauses for a second before moving on to the next line, as expected. However, when I try to enter a command like
x = randn(100,100)
I get a message saying
name 'randn' is not defined
Also, when I run
imp.find_module("pandas")
I get
(None, 'C:\\Anaconda\\lib\\site-packages\\numpy', ('', '', 5))
Any ideas?
Your message title refers to scipy
, but you didn't import anything from it, so I'm not sure why that's relevant. You did two imports:
from pandas import *
which I wouldn't actually recommend; I know it's done in some tutorials, but I prefer
import pandas as pd
to keep the namespace clean. In any case, randn
isn't defined in the pandas
namespace. Then you run
from numpy import random
which only adds one new name to the namespace: random
. After you've done this, you can access randn
via random.randn
:
>>> from numpy import random
>>> random.randn(3)
array([-1.19504793, -0.54873061, -1.46225504])
If you really want to use simply randn
, you could do
from numpy.random import randn
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With