Different Ways of Creating DataFrame With Python
Helpful functions for data science and machine learning
4 min readApr 29, 2022
This article will get you familiar with different ways of creating a pandas dataframe with python in the jupyter notebook.
Topics to be covered:
- Reading and creating data frame with csv function
- Reading and creating data frame with excel function
- Reading and creating data frame with python dictionary
- Reading and creating a data frame with a list of tuples
- Reading and creating a data frame with a list of dictionaries
- Reading and creating a data frame with CSV function
In this topic, we will read the CSV file with the help of panda’s in-built function. Here, we are using the read_csv function to read the CSV file and create a data frame by saving it to the variable.
Example
import pandas as pd
df = pd.read_csv('ipl.csv')
df.head(2)
#output:
2. Reading and creating a data frame with excel function
In this topic, we will read the excel file with the help of panda’s in-built function. Here, we are using the read_excel function to read the excel file and…