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