I have a DataFrame using pandas and column labels that I need to edit to replace the original column labels.
I\'d like to change the column names in a DataFrame
I needed to rename features for XGBoost, it didn't like any of these:
import re regex = r"[!\"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~ ]+" X_trn.columns = X_trn.columns.str.replace(regex, '_', regex=True) X_tst.columns = X_tst.columns.str.replace(regex, '_', regex=True)