cambiar el nombre de las columnas pandas
df.rename(columns={'oldName1': 'newName1',
'oldName2': 'newName2'},
inplace=True, errors='raise')
# Make sure you set inplace to True if you want the change
# to be applied to the dataframe
cambiar el nombre de la columna pandas
>>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
>>> df.rename(columns={"A": "a", "B": "c"})
a c
0 1 4
1 2 5
2 3 6
python cómo cambiar el nombre de las columnas en pandas dataframe
# Basic syntax:
# Assign column names to a Pandas dataframe:
pandas_dataframe.columns = ['list', 'of', 'column', 'names']
# Note, the list of column names must equal the number of columns in the
# dataframe and order matters
# Rename specific column names of a Pandas dataframe:
pandas_dataframe.rename(columns={'column_name_to_change':'new_name'})
# Note, with this approach, you can specify just the names you want to
# change and the order doesn't matter
# For rows, use "index". E.g.:
pandas_dataframe.index = ['list', 'of', 'row', 'names']
pandas_dataframe.rename(index={'row_name_to_change':'new_name'})
cambiar el nombre de la columna pandas dataframe
df.rename(columns={"old_col1": "new_col1", "old_col2": "new_col2"})
pandas cambiar el nombre de la columna
df.rename(columns={"old_col1": "new_col1", "old_col2": "new_col2"}, inplace=True)
cambiar el nombre de la columna df
import pandas as pd
data = pd.read_csv(file)
data.rename(columns={'original':'new_name'}, inplace=True)