Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get descriptive statistics of a NumPy array?

I use the following code to create a numpy-ndarray. The file has 9 columns. I explicitly type each column:

dataset = np.genfromtxt("data.csv", delimiter=",",dtype=('|S1', float, float,float,float,float,float,float,int)) 

Now I would like to get some descriptive statistics for each column (min, max, stdev, mean, median, etc.). Shouldn't there be an easy way to do this?

I tried this:

from scipy import stats stats.describe(dataset) 

but this returns an error: TypeError: cannot perform reduce with flexible type

How can I get descriptive statistics of the created NumPy array?

like image 522
beta Avatar asked Jul 26 '16 07:07

beta


People also ask

How do you describe an NP array?

Arrays. A numpy array is a grid of values, all of the same type, and is indexed by a tuple of nonnegative integers. The number of dimensions is the rank of the array; the shape of an array is a tuple of integers giving the size of the array along each dimension.

Does NumPy describe a function?

NumPy is a Python library used for numerical computing. It offers robust multidimensional arrays as a Python object along with a variety of mathematical functions. In this article, we will go through all the essential NumPy functions used in the descriptive analysis of an array.


1 Answers

import pandas as pd import numpy as np  df_describe = pd.DataFrame(dataset) df_describe.describe() 

please note that dataset is your np.array to describe.

import pandas as pd import numpy as np  df_describe = pd.DataFrame('your np.array') df_describe.describe() 
like image 146
INNO TECH Avatar answered Sep 24 '22 13:09

INNO TECH