Descriptive Statistics
Descriptive statistics are measures that summarize important features of data, often with a single number. Producing descriptive statistics is a common first step to take after cleaning and preparing a data set for analysis.
- Data Frame
2. Sum
Returns the sum of the values for the requested axis. By default, axis is index (axis=0).
3.Mean
Returns the average value
4.Std
Returns the Bressel standard deviation of the numerical columns.
5. describe
The describe() function computes a summary of statistics pertaining to the DataFrame columns.
Array of Random Integer Values
An array of random integers can be generated using the randint() NumPy function.
This function takes three arguments, the lower end of the range, the upper end of the range, and the number of integer values to generate or the size of the array. Random integers will be drawn from a uniform distribution including the lower value and excluding the upper value, e.g. in the interval [lower, upper).
The example below demonstrates generating an array of random integers.
# generate random integer values
from numpy.random import seed
from numpy.random import randint
# seed random number generator
seed(1)
# generate some integers
values = randint(0, 10, 20)
print(values)
Running the example generates and prints an array of 20 random integer values between 0 and 10.
>>>[5 8 9 5 0 0 1 7 6 9 2 4 5 2 4 2 4 7 7 9]
Generating Random Numbers With NumPy
import numpy as np
Generate A Random Number From The Normal Distribution
np.random.normal()
0.5661104974399703
Generate Four Random Numbers From The Normal Distribution
np.random.normal(size=4)
array([-1.03175853, 1.2867365 , -0.23560103, -1.05225393])
Generate Four Random Numbers From The Uniform Distribution
np.random.uniform(size=4)
array([ 0.00193123, 0.51932356, 0.87656884, 0.33684494])
Generate Four Random Integers Between 1 and 100
np.random.randint(low=1, high=100, size=4)
array([96, 25, 94, 77])