Skip to main content
100%

Gist d55d478bb85bfb424d4ea80f2af06d2a

✓ Published0🌍 Public
Aadiamaan92
Last edited Jan 28, 2019
Created on Jan 28, 2019

This example demonstrates a utility function that renames the columns of a pandas DataFrame. It shows how to apply a custom naming scheme, such as joining multi-level column labels with an underscore, or replacing the column names with an explicit list. The function `setcols` accepts a DataFrame and an optional function or list; when no list is provided, it maps the given function across the existing column index. The code relies on pandas’ `columns` attribute and the `map` method, making it a concise tool for data preprocessing before visualization.

AI-generated description

Similar vizzes