Q. Write a small Python code to create a dataframe with headings (a and b) from the list given below:


[[1,2],[3,4],[5,6],[7,8]]

Answer :-

 

import pandas as pd
df = pd. DataFrame ([[1, 2], [3, 4]], columns = ['a', 'b'])
df2 = pd. DataFrame ([[5, 6], [7, 8]], columns = ['a', 'b'])
df = df.append(df2)
print (df)


Output :-

   a  b
0  1  2
1  3  4
0  5  6
1  7  8

>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post