We will learn how to handle correlation between arrays in the Numpy Python library.
To calculate correlation between two arrays in Numpy, you need to use the corrcoef function.
import numpy as np my_array = np.array([1, 2, 4, 7, 17, 43, 4, 9]) second_array = np.array([2, 12, 5, 43, 5, 76, 23, 12]) correlation_arrays = np.corrcoef(my_array, second_array) print(f"Correlation between two arrays: \n {correlation_arrays}")
The Corrcoef function returns a correlation matrix as an output.