Replace column name on Pandas Dataframe



    Javier Pacheco

    The code will rename all the column in the dataframe to the specified values.

    import pandas as pd
    df.rename(columns = {'col1':'replace1', 'col2':'replace2', 'col3':'replace3'}, inplace = True)
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.