Python Forum

Full Version: numpy and statistics module
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
you need to load package statstics
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