# Pearson Correlation of same values

I got this problem while computing the pearson correlation of two datasets where one set consists of the same value. For example this pandas DataFrame:

tdf = pd.DataFrame([[1, 2], [1, 2], [1, 2]], columns=["a", "b"])
tdf.corr()


As a results from pandas correlation function I just geht 'NaN' values. I guess it is because the nominator and denominator from pearson formula are zero. But shouldn't the correlation value should be '1'? Do I missunderstand something?

• Welcome to CV. Since you’re new here, you may want to take our tour, which has information for new users. You already gave the answer, the standard deviation is zero. Why should there be a correlation of 1? Try instead $(1,2,3)$ for both variables. – T.E.G. Jan 29 at 13:51
• Think of this graphically or geometrically. You have three points that will plot at the same position. The algebra says that they all follow $b = 2a$ (in your notation) but the geometry does not define a unique straight-line summary. (I recommend thinking of these as two variables, not two datasets.) – Nick Cox Jan 29 at 18:17