Python Forum
numpy and statistics module
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
numpy and statistics module
#1
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
Reply
#2
you need to load package statstics
Reply
#3
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 288 Mar-26-2024, 02:18 PM
Last Post: snippsat
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,528 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  AttributeError: module 'numpy' has no attribute 'array aapurdel 7 45,259 May-29-2019, 02:48 AM
Last Post: heiner55
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 2,927 Apr-09-2019, 04:54 PM
Last Post: PhysChem
  No module named numpy rdx 7 59,048 Sep-24-2017, 07:12 AM
Last Post: Larz60+
  Statistics: Two histograms based on word frequency vectors fancy_panther 2 4,709 Mar-27-2017, 01:18 AM
Last Post: zivoni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020