What happens to the correlation coefficient if one of the variables is constant or has zero variance?

Quick Overview

Asks what the Pearson correlation coefficient becomes when one variable is constant or has zero variance. Tests reading the correlation formula, knowing how pandas and NumPy report the result, and handling zero-variance and near-constant columns in a real analysis.

What happens to the correlation coefficient if one of the variables is constant or has zero variance?

Role: Data Scientist

Category: Statistics & Math

Difficulty: easy

Interview Round: Other

What happens to the correlation coefficient if one of the variables is constant or has zero variance? ```hint Look at the formula Write out the Pearson formula and check what every deviation from the mean is for a constant variable, in the numerator as well as the denominator. ``` ### What a Strong Answer Covers - What the Pearson formula evaluates to when one standard deviation is zero, numerator included - Whether the result is zero or undefined, and why - How common tools such as pandas and NumPy report the result - How to detect and handle zero-variance columns in a real analysis - What changes when a column is nearly constant instead of exactly constant ### Follow-up Questions - Is the Spearman rank correlation defined when one variable is constant? - A feature has a variance of about ${10^{-12}}$ instead of exactly zero. What problems can that cause? - A column is constant in the training data but varies in production. What breaks? - Why can filling NaN correlations with 0 in a feature-screening step be misleading?

Overview: Asks what the Pearson correlation coefficient becomes when one variable is constant or has zero variance. Tests reading the correlation formula, knowing how pandas and NumPy report the result, and handling zero-variance and near-constant columns in a real analysis.

General logo
General
Nov 24, 2026
easyData ScientistOtherStatistics & Math
0
0

What happens to the correlation coefficient if one of the variables is constant or has zero variance?

What a Strong Answer Covers Guidance

  • What the Pearson formula evaluates to when one standard deviation is zero, numerator included
  • Whether the result is zero or undefined, and why
  • How common tools such as pandas and NumPy report the result
  • How to detect and handle zero-variance columns in a real analysis
  • What changes when a column is nearly constant instead of exactly constant

Follow-up Questions Guidance

  • Is the Spearman rank correlation defined when one variable is constant?
  • A feature has a variance of about 10−12{10^{-12}} instead of exactly zero. What problems can that cause?
  • A column is constant in the training data but varies in production. What breaks?
  • Why can filling NaN correlations with 0 in a feature-screening step be misleading?