In [1]:
from pandas import DataFrame
import pandas as pd

This is the data frame you are given

In [2]:
# Create some data
d = {0:[2,7],
     1:[2,3],
     'sum':[4,10]
     }
d
Out[2]:
{0: [2, 7], 1: [2, 3], 'sum': [4, 10]}
In [3]:
# Create the data frame
frm = DataFrame(data=d)
frm
Out[3]:
0 1 sum
0 2 2 4
1 7 3 10

This is the data frame you have to replicate

  • Add a new row
In [4]:
ans = {0:[2,7,1],
       1:[2,3,1],
       'sum':[4,10,2]
       }

frm_ans = DataFrame(data=ans)
frm_ans
Out[4]:
0 1 sum
0 2 2 4
1 7 3 10
2 1 1 2

Start Coding...

In [4]:
 
In [4]:
 

How check your answer?

The correct answer will have "True" on all the rows.

In [5]:
# "Yout data frame" == frm
frm_ans == frm_ans
Out[5]:
0 1 sum
0 True True True
1 True True True
2 True True True
Back to top