Different Ways of Creating DataFrame With Python

Helpful functions for data science and machine learning

Amit Chauhan
4 min readApr 29, 2022
Photo by Tai Bui on Unsplash

This article will get you familiar with different ways of creating a pandas dataframe with python in the jupyter notebook.

Topics to be covered:

  1. Reading and creating data frame with csv function
  2. Reading and creating data frame with excel function
  3. Reading and creating data frame with python dictionary
  4. Reading and creating a data frame with a list of tuples
  5. Reading and creating a data frame with a list of dictionaries
  6. 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…

--

--