Python Forum
numpy and statistics module - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: numpy and statistics module (/thread-5085.html)



numpy and statistics module - baronmontesqieu - Sep-18-2017

hello.
I am trying to get familiar with numpy and statstics module on python

the latter is program i made to input any list and try to find the standard deviation of the list

i am getting an error; please check on this.

thank you very much.

the latter is code

import numpy
import statistics

rawstr = raw_input("type a 4-list of integers")
rawstr1 = raw_input("type a 4-list of integers")
rawstr2 = raw_input("type a 4-list of integers")
ival = list(rawstr)
ival1 = list(rawstr1)
ival2 = list(rawstr2)

arr = numpy.array([ival1,ival2,ival3])
statistics.stdev(arr)
the latter is error
Error:
ImportError Traceback (most recent call last) <ipython-input-1-ffd1ea567921> in <module>() 1 import numpy ----> 2 import statistics 3 4 rawstr = raw_input("type a 4-list of integers") 5 rawstr1 = raw_input("type a 4-list of integers") ImportError: No module named statistics
thank you


RE: numpy and statistics module - Larz60+ - Sep-18-2017

you need to load package statstics


RE: numpy and statistics module - snippsat - Sep-18-2017

statistics was new in version 3.4.
So use Python 3.6, Win, Linux.

There are several problem with that code.
No need to use Numpy,if use statistics.
Numpy has own statistics.
Need to convert to integers.
import statistics

rawstr1 = input("type a 4-list of integers: ")
rawstr2 = input("type a 4-list of integers: ")
ival1 = [int(i) for i in list(rawstr1)]
ival2 = [int(i) for i in list(rawstr2)]
print(statistics.stdev(ival1 + ival2))
Output:
E:\1py_div\div_code λ python num.py type a 4-list of integers: 1234 type a 4-list of integers: 4567 2.0