Answers for "why is renaming a column so hard in pandas"

8

rename df column

import pandas as pd
data = pd.read_csv(file)
data.rename(columns={'original':'new_name'}, inplace=True)
Posted by: Guest on June-02-2020
0

pandas description of dataframe renaming column values

dict = {
    'Android': 'Android',
    'Chrome OS': 'Chrome OS',
    'Linux': 'Linux',
    'Mac OS': 'macOS',
    'No OS': 'No OS',
    'Windows': 'Windows',
    'macOS': 'macOS'
}

df['col'] = df['col'].map(dict)
Posted by: Guest on July-27-2021

Code answers related to "why is renaming a column so hard in pandas"

Python Answers by Framework

Browse Popular Code Answers by Language