Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)
Can anyone tell me how to create a DataFrame in Python?

1 Answer

0 votes
by (108k points)
edited by

For creating the data frame, you need to first import the pandas package and then with the help of pandas package, you will be creating a dictionary and convert that dictionary into data frame:

import pandas as pd

marksheet = {'Name': ['Tarun','Carl','Ford','Arun'],

        'Marks': ['22/50','25/50','27/50','30/50']

        }

 

df = pd.DataFrame(marksheet, columns = ['Name', 'Marks'])

 

print (df)

The output is:

     Name  Marks

0  Tarun  22/50

1   Carl  25/50

2   Ford  27/50

3   Arun  30/50

If you are looking for an online course to learn Python, I recommend this Python Online Course by Intellipaat.

Browse Categories

...