How to Skip Columns in Sweetviz Reports with Python

This quick tutorial shows how to exclude specific columns from Sweetviz analysis reports using the FeatureConfig class. For a complete introduction to automated exploratory data analysis, see our Automated Exploratory Data Analysis with Sweetviz in Python guide.

The Problem

When generating Sweetviz reports, you often have columns that clutter the analysis without adding value. ID columns, row numbers, and redundant features take up space in your reports and slow down processing time. When comparing datasets, including the filtering column itself causes type conflicts and errors. You need a clean way to tell Sweetviz which columns to ignore while keeping everything else in the analysis.

The Solution

Sweetviz provides the FeatureConfig class with a skip parameter that excludes columns from your reports. Pass a list of column names you want to remove before generating the analysis.

Here’s how to skip columns in a basic analysis report:

 
import sweetviz as sv
import seaborn as sns

df = sns.load_dataset('titanic')
config = sv.FeatureConfig(skip=['deck', 'embark_town', 'alive'])
report = sv.analyze(df, feat_cfg=config)
report.show_html('filtered_analysis.html')

The FeatureConfig(skip=[…]) creates a configuration object that tells Sweetviz to exclude the listed columns. The deck, embark_town, and alive columns won’t appear in the generated report, making it more focused on the remaining variables.

skip columns sweetviz python 

This becomes especially useful when comparing datasets. If you filter by passenger class and want to compare first class versus third class passengers, you must skip the pclass column itself:

 
first_class = df[df["pclass"] == 1].copy()
third_class = df[df["pclass"] == 3].copy()

config = sv.FeatureConfig(skip=['pclass'])
comparison = sv.compare([first_class, "First Class"], 
                        [third_class, "Third Class"],
                        feat_cfg=config)
comparison.show_html('class_comparison.html')

skip columns sweetviz python 

Without skipping pclass, Sweetviz throws errors because the column contains different values in each subset (all 1s in first class, all 3s in third class). Skipping resolves the type conflict and produces a clean comparison report.

When to Skip Columns

Skip ID columns and row indices that serve no analytical purpose. When working with duplicate features that represent the same information differently, keep the most useful version and skip the rest. For target variable analysis, you typically want to include your target, but when comparing train and test sets, skip any columns that differ structurally between the sets. The skip parameter accepts any valid column name from your dataframe, so you can build the list dynamically based on column properties like data type or missing value percentage.

Conclusion

The FeatureConfig skip parameter gives you precise control over which columns appear in Sweetviz reports. Use it to remove clutter, avoid comparison errors, and focus your analysis on relevant features.

Leave a Reply

Your email address will not be published. Required fields are marked *