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?
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.
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.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With