Quite new into pandas, I have generated a new column from division of last_value /first_value row in a this df.
df=
     data1 data2 
A      4    3
B      4    3
C      5    3
D      1    9
I generated this new column (with no headers)
new_column= df.loc[D]/df.loc[A]
new_column=
data1   0.25
data2   3
I have tried to add a header 'results' through :
new_column.rename(columns={0 :'results'}, inplace=True)
new_column.rename(columns={'0' :'results'}, inplace=True)
new_column['results']= df.loc[D]/df.loc[A]
print (new_column)
From the research done, nothing seems to work/adapt:
Adding Column Headers to new pandas dataframe
The result is the same without any headers.How can I include the header?
What I am looking for is :
       results
data1   0.25
data2   3
In short the new_column with the header 'results'
 
     
     
     
    