I am still learning coding and would be grateful for any help that I can get.
I have a dataframe where a person's name is the column header. I would like to shift the column header down 1 row and rename the column 'Name'. The column header will be different with each dataframe, though. It won't always be the same person's name.
Here is an example of one of the dataframes:
index Patrick
0 Stan
1 Frank
2 Emily
3 Tami
I am hoping to shift the entire column with names down 1 row and rename the column header 'Names' but am unable to find this during my research.
Here is an example of the desired output:
index Names
0 Patrick
1 Stan
2 Frank
3 Emily
4 Tami
I have seen the option to use 'shift', however, I do not know if this will work correctly in this case.
I will post the url below for a similar problem that was been asked. In this problem they want to shift up by one. In my problem I want to shift down by one.
Shift column in pandas dataframe up by one?
The code example I found online is below:
df.gdp = df.gdp.shift(-1)
The issue I see is that I will be using multiple dataframes so the person's name (column header) will be different. I won't have the same name each time.
Any help? I will continue to work and this and will post the answer if I am able to find it. Thanks in advance for any help that you may offer.