Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is wrong with this extremely simple numpy script? [closed]

Tags:

python

numpy

I run the following in Python 2.7

import numpy
a = numpy.ndarray(shape=(2,2), dtype=float, order='F')
print numpy.mean(a)
numpy.savetext('foo.txt', a)

and get this result

[me@foo bar]$ python f.py 
8.79658981512e-317
Traceback (most recent call last):
  File "f.py", line 4, in <module>
    numpy.savetext('foo.txt', a)
AttributeError: 'module' object has no attribute 'savetext'

What's wrong?

like image 463
user3268289 Avatar asked May 13 '14 19:05

user3268289


People also ask

How do I import a NumPy library into Python?

There are two ways to install numpy: Install the binary (pre-compiled) version using pip. Compile it from source code, and then install it.

What is a correct syntax to create a NumPy array?

The array object in NumPy is called ndarray . We can create a NumPy ndarray object by using the array() function.


1 Answers

It's numpy.savetxt, without the e.

like image 132
unutbu Avatar answered Sep 21 '22 21:09

unutbu