Saya baru mengenal ilmu data dan baru saja menginstal numpy
di sistem. Jadi, saya terjebak di suatu tempat ketika saya menjalankan numpy.mean(num)
fungsi untuk menghitung rata-rata dari array angka. Jadi, adakah yang bisa menyarankan solusinya?
Saya menggunakan Ubuntu 17.04. Berikut ini adalah kode untuk kesalahan:
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> num = {1,2,3,4,5,6,7}
>>> import numpy
>>> numpy.mean(num)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/vaibhav/.local/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 2909, in mean
out=out, **kwargs)
File "/home/vaibhav/.local/lib/python2.7/site-packages/numpy/core/_methods.py", line 82, in _mean
ret = ret / rcount
TypeError: unsupported operand type(s) for /: 'set' and 'int'
>>> numpy.median(num)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/vaibhav/.local/lib/python2.7/site-packages/numpy/lib/function_base.py", line 4102, in median
overwrite_input=overwrite_input)
File "/home/vaibhav/.local/lib/python2.7/site-packages/numpy/lib/function_base.py", line 4016, in _ureduce
r = func(a, **kwargs)
File "/home/vaibhav/.local/lib/python2.7/site-packages/numpy/lib/function_base.py", line 4160, in _median
return mean(part[indexer], axis=axis, out=out)
File "/home/vaibhav/.local/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 2909, in mean
out=out, **kwargs)
File "/home/vaibhav/.local/lib/python2.7/site-packages/numpy/core/_methods.py", line 82, in _mean
ret = ret / rcount
TypeError: unsupported operand type(s) for /: 'set' and 'int'