Renaming dataframe columns via User Defined Function via Pandas
Instead of doing:
df=df.apply(modname)

You should do:
df = modname(df)


i'm trying to rename dataframe columns through User Defined Function without success.
In particular it seems that doesn't exist "rename" method when called inside a UDF.
Following an example to better explain my problem:
import pandas as pd`

data = {'Age': [21, 19, 20, 18,80,90],'Stream': [88, 65,99, 765,65,55],'Percentage': [88, 92, 95, 70,55,47]}

df = pd.DataFrame(data, columns=['Age', 'Stream', 'Percentage'])

print("Given Dataframe :n", df)

def modname(frame):


    frame=frame.rename(columns={'Age':'aa','Stream':'bb','Percentage':'cc'})
    
    return frame

df=df.apply(modname)

print(df)

`
I greatly appreciate your help
i tried the same code without UDF and it works
