Create a DataFrame From Scratch

python

This is a very short post on how to create a dataFrame from scratch.

Let’s import the Pandas library

# Import
import pandas as pd

Now we create a dataFrame

Creating two arrays first:

name = ["John", "Mark", "Julie"]
age = [32, 34, 25]

We can now make a dataFrame out of the two arrays previously created:

df = pd.DataFrame({'Name': name, 'Age': age})
df
Name Age
0 John 32
1 Mark 34
2 Julie 25

Et voila!

Share this post: