I am just starting to use user-defined functions, so this is probably not a very complex question, forgive me.
I have a few dataframes, which all have a column named 'interval_time' (for example) and I would like to rename this column 'Timestamp'.
I know that I can do this manually with this;
df = df.rename(index=str, columns={'interval_time': 'Timestamp'})
but now I would like to define a function called rename that does this for me. I have seen that this works;
def rename(data):
print(data.rename(index=str, columns={'interval_time': 'Timestamp'}))
but I can't seem to figure out to save the renamed dataframe, I have tried this;
def rename(data):
data = data.rename(index=str, columns={'interval_time': 'Timestamp'})
The dataframes that I am using have the following form;
df_scada
interval_time A ... X Y
0 2010-11-01 00:00:00 0.0 ... 396.36710 381.68860
1 2010-11-01 00:05:00 0.0 ... 392.97974 381.40634
2 2010-11-01 00:10:00 0.0 ... 390.15695 379.99493
3 2010-11-01 00:15:00 0.0 ... 389.02786 379.14810