Skip to content
C

Problem 3: Remove Low-Variance Features

Easypython

Problem Description

Write a Python program that identifies and removes any numeric column whose variance is below a given threshold.

Input

A DataFrame with numeric columns, and a variance threshold value.

Output

The DataFrame with low-variance columns removed, and a list of which columns were dropped.

Constraints

  • Threshold will be a small positive number (e.g., 0.01).

Example Input

text
{"a": [1,1,1,1], "b": [10,20,30,40]}, threshold=0.01

Example Output

text
Dropped columns: ['a'] Remaining columns: ['b']

Concepts Covered

.var(), conditional column filtering.

Input (stdin)

Output

Run your code to see output here...