I'm trying to change my dataframe columns names , i tried two methods but none of them worked . here is my code ;
method 1 :
def func():
energy=pd.ExcelFile('Energy Indicators.xls').parse('Energy')
energy=energy.iloc[16:][['Environmental Indicators: Energy','Unnamed:3','Unnamed: 4','Unnamed: 5']].copy() energy.columns()=['Country',
'Energy Supply', 'Energy Supply per Capita', '%Renewable']
return energy
method 2:
def func():
energy=pd.ExcelFile('Energy Indicators.xls').parse('Energy')
energy=energy.iloc[16:][['Environmental Indicators: Energy','Unnamed: 3','Unnamed: 4','Unnamed: 5']].copy()
return energy.rename(columns={'Environmental Indicators: Energy': 'Country', 'Unnamed: 3': 'Energy Supply',
'Unnamed: 4': 'Energy Supply per Capita', 'Unnamed: 5': '% Renewable'}, inplace=True)
Both of them return a NoneType Object .
Here is the .xls file i'm working on : https://drive.google.com/file/d/0B80lepon1RrYeDRNQVFWYVVENHM/view?usp=sharing