I want to rename the column names of a dataframe that I have using Column Rename Regex:
As an example, here are some of the column names:
Test|Weight|Day1Hour4|F|True
Test|Weight|Day1Hour12|F|True
Test|Weight|Day1Hour-0.833|F|True
Test|Weight|Day1Hour0.5|F|True
Test|Weight|Day1Hour-84|F|True
What I want to do, is to add the string _Test at the end of the time, so I would get this:
Test|Weight|Day1Hour4_Test|F|True
Test|Weight|Day1Hour12_Test|F|True
Test|Weight|Day1Hour-0.833_Test|F|True
Test|Weight|Day1Hour0.5_Test|F|True
Test|Weight|Day1Hour-84_Test|F|True
The first thing I tried was:
But of course, this is not working properly:
Test|Weight|Day1Hour4_Test|F|True
Test|Weight|Day1Hour12_Test|F|True
Test|Weight|Day1Hour-0._Test833|F|True
Test|Weight|Day1Hour0._Test5|F|True
Test|Weight|Day1Hour-0.84|F|True
I though of encapsulating the last part of the string, using this:
But for some reason it adds the string _Test at the end, like in:
Test|Weight|Day1Hour4|F|True_Test
Of course I could rowsplit the data and execute two different column rename regex and then join, but I have a LOT of columnsto rename, and this would take a lot of time.
So I would love to know if there’s a way of renaming them all at the same time, with just one regex command (or other option).