Python numpy.corrcoef() RuntimeWarning: invalid value encountered in true_divide c /= stddev[:, None]
问题 It seems that corrcoef from numpy throw a RuntimeWarning when a constant list passed to the corrcoef() function, for example the below code throw a warning : import numpy as np X = [1.0, 2.0, 3.0, 4.0] Y = [2, 2, 2, 2] print(np.corrcoef(X, Y)[0, 1]) Warning : /usr/local/lib/python3.6/site-packages/numpy/lib/function_base.py:3003: RuntimeWarning: invalid value encountered in true_divide c /= stddev[:, None] Can anyone explain why it's throw this error when one of the lists is constant, and how