In [1]:
from pandas import DataFrame

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

  • Change the column name
  • Change the index name
In [4]:
ans = {0:[2,7],
       'energy':[2,3],
       'sum':[4,10]
       }

idx = [0,'row']

frm_ans = DataFrame(data=ans, index=idx)
frm_ans
Out[4]:
0 energy sum
0 2 2 4
row 7 3 10

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 energy sum
0 True True True
row True True True
Back to top