Insert a row on the Dataframe at the bottom and calculate the sum

I have a dataframe which has many columns, I want to insert a new row to calculate the sum of the last 2 columns. I tried to use concat function but doesnt works. It add a new column not a new row. Is there has a solution?

Dataframe looks like this:

Date.      A.  B.  C.  D
2021-03-01 5.  10. 15. 20
2021-03-02 5.  10  5.  5
2021-03-03.5.  10. 10. 5

I tried to create a blank dataframe and concat the original DataFrame but the output was wrong.

new_df = pd.DataFrame(columns=['Date'])
merge_df = pd.concat([returns,new_df])

I want the result like that:

Date.      A.  B.  C.  D
2021-03-01 5.  10. 15. 20
2021-03-02 5.  10  5.  5
2021-03-03.5.  10. 10. 5
sum_2      10  20. 15. 10

Answer

Adding df:

import pandas as pd

df = pd.DataFrame({
                     "A": [5, 10, 15, 20],
                    "B": [5, 10, 15, 5],
                    "C": [5, 10, 5, 5],
                    "D": [5, 10, 10, 5]})

Summing total:

df.loc["Row_Total"] = df.sum()
df

Summing only last 2 rows:

iloc – https://www.kite.com/python/answers/how-to-get-the-last-n-rows-from-a-pandas-dataframe-in-python

https://www.kite.com/python/docs/pandas.DataFrame.iloc

df.loc["Row_Total"] = df.iloc[-2:].sum()