Preview:
def clean_feature_names(feature_names, df_cols):
    feature_names = [f_name.replace('onehotencoder__', '') for f_name in feature_names]
    for i, col_name in enumerate(df_cols):
        feature_names = [f_name.replace('x' + str(i) + '_', col_name + '_') for f_name in feature_names]
    return feature_names
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter