How to change name of existing data frame to newname that stored in variable.
newName = 'rSK_' + dimName.replace(' ', '') # rSK_TradeFlow
df.rename(newName) # this is not working
You actually have already achieved what you want when you assign the data to a new variable name.
Say for example you have a dataframe called df_original, if you assign it to a new variable called 'df_new' such as:
df_new = df_original
In this case, the data frame is NOT copied, it just gets a new name that refers to the original data saved in the memory.
If you run 'df_new is df_original' the output is 'True'. So these are just different names pointing to the same dataset saved in the memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With