[Solved] Write a Python code to create a dataframe with headings ( a and b ) from the list given below

   RSS

1
Topic starter

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

[ [ 1,2 ],[ 3,4 ],[ 5,6 ],[ 7,8 ] ]
1 Answer
1
Topic starter

Code:

import pandas as pd


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


df = pd.DataFrame(data, columns=["a","b"])


print(df)

Output:

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